![]() |
#2
吹水佬2022-09-15 12:13
|
有没有比较了解这个函数的兄弟,帮忙解释一下?
1,点击header的时候,nwhere_out参数为0,按理应该返回1
2,点击Cell的时候,nRow_out可以得到正确的参数,nCol_out=0(按理赢显示第几列),nwhere_out=0(按理应该为3)
3,有数据时,这个函数在数据区不输出nRow_out,nCol_out,nwhere_out
4,鼠标移动到header之间是,nwhere_out应该为2,结果也是0
贴上测试代码

**************************************************
*-- Form: form1 (d:\documents\visual foxpro 项目\gridhittest.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 09/14/22 09:17:00 PM
*
DEFINE CLASS form1 AS form
Top = 1
Left = 0
Height = 504
Width = 681
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT grid1 AS grid WITH ;
Height = 288, ;
Left = 12, ;
Top = 12, ;
Width = 516, ;
Name = "Grid1"
ADD OBJECT label1 AS label WITH ;
Caption = "点击位置", ;
Height = 16, ;
Left = 12, ;
Top = 312, ;
Width = 54, ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
Caption = "行号", ;
Height = 16, ;
Left = 12, ;
Top = 336, ;
Width = 38, ;
Name = "Label2"
ADD OBJECT label3 AS label WITH ;
Caption = "列号", ;
Height = 16, ;
Left = 12, ;
Top = 360, ;
Width = 38, ;
Name = "Label3"
ADD OBJECT label4 AS label WITH ;
Caption = "所在窗格", ;
Height = 16, ;
Left = 12, ;
Top = 384, ;
Width = 54, ;
Name = "Label4"
ADD OBJECT text1 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 312, ;
Width = 100, ;
Name = "Text1"
ADD OBJECT text2 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 333, ;
Width = 100, ;
Name = "Text2"
ADD OBJECT text3 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 354, ;
Width = 100, ;
Name = "Text3"
ADD OBJECT text4 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 375, ;
Width = 100, ;
Name = "Text4"
ADD OBJECT label5 AS label WITH ;
Caption = "当前X:", ;
Height = 16, ;
Left = 240, ;
Top = 310, ;
Width = 38, ;
Name = "Label5"
ADD OBJECT label6 AS label WITH ;
Caption = "当前Y:", ;
Height = 16, ;
Left = 240, ;
Top = 340, ;
Width = 38, ;
Name = "Label6"
ADD OBJECT text5 AS textbox WITH ;
Height = 20, ;
Left = 290, ;
Top = 310, ;
Width = 100, ;
Name = "Text5"
ADD OBJECT text6 AS textbox WITH ;
Height = 20, ;
Left = 290, ;
Top = 340, ;
Width = 100, ;
Name = "Text6"
ADD OBJECT text7 AS textbox WITH ;
Height = 31, ;
Left = 290, ;
Top = 370, ;
Width = 151, ;
Name = "Text7"
ADD OBJECT text8 AS textbox WITH ;
Height = 20, ;
Left = 490, ;
Top = 340, ;
Width = 100, ;
Name = "Text8"
ADD OBJECT text9 AS textbox WITH ;
Height = 20, ;
Left = 490, ;
Top = 370, ;
Width = 100, ;
Name = "Text9"
PROCEDURE MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.text8.Value=nxcoord
thisform.text9.Value=nycoord
ENDPROC
PROCEDURE grid1.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
LOCAL nXCoord, nYCoord, nWhere_Out, nRow_Out, nCol_Out, nView_Out
nwhere_out=0
nrow_out=0
ncol_out=0
nview_out=0
tf=this.GridHitTest(nXCoord, nYCoord, @nWhere_Out, @nRow_Out, @nCol_Out, @nView_Out)
IF tf=.t.
thisform.text1.Value=nwhere_out
thisform.text2.Value=nrow_out
thisform.text3.Value=ncol_out
thisform.text4.Value=nview_out
ENDIF
thisform.text5.Value=nxcoord
thisform.text6.Value=nycoord
thisform.CurrentX=nxcoord
thisform.CurrentY=nycoord
ENDPROC
PROCEDURE grid1.Init
temptable=SYS(2015)
CREATE TABLE &temptable FREE (颜色 c(30), XS N(5),S N(5),M N(5),L N(5),XL N(5),XXL N(5),TOTAL n(6))
this.RecordMark=.t.
this.DeleteMark=.f.
this.SetAll('alignment',2,'header')
this.headerheight=35
this.RowHeight=25
this.recordsource=temptable
this.AllowAddNew=.t.
APPEND BLANK
ENDPROC
PROCEDURE grid1.Click
nxcoord=thisform.CurrentX
nycoord=thisform.CurrentY
STORE 0 TO nwhere_out,nrow_out,ncol_out,nview_out
isclicked=this.GridHitTest(nXCoord, nYCoord, @nWhere_Out, @nRow_Out, @nCol_Out, @nView_Out)
IF isclicked
thisform.text1.Value=nwhere_out
ENDIF
ENDPROC
PROCEDURE text7.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
*NODEFAULT
thisform.text8.Value=nxcoord
thisform.text9.Value=nycoord
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************
*-- Form: form1 (d:\documents\visual foxpro 项目\gridhittest.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 09/14/22 09:17:00 PM
*
DEFINE CLASS form1 AS form
Top = 1
Left = 0
Height = 504
Width = 681
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT grid1 AS grid WITH ;
Height = 288, ;
Left = 12, ;
Top = 12, ;
Width = 516, ;
Name = "Grid1"
ADD OBJECT label1 AS label WITH ;
Caption = "点击位置", ;
Height = 16, ;
Left = 12, ;
Top = 312, ;
Width = 54, ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
Caption = "行号", ;
Height = 16, ;
Left = 12, ;
Top = 336, ;
Width = 38, ;
Name = "Label2"
ADD OBJECT label3 AS label WITH ;
Caption = "列号", ;
Height = 16, ;
Left = 12, ;
Top = 360, ;
Width = 38, ;
Name = "Label3"
ADD OBJECT label4 AS label WITH ;
Caption = "所在窗格", ;
Height = 16, ;
Left = 12, ;
Top = 384, ;
Width = 54, ;
Name = "Label4"
ADD OBJECT text1 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 312, ;
Width = 100, ;
Name = "Text1"
ADD OBJECT text2 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 333, ;
Width = 100, ;
Name = "Text2"
ADD OBJECT text3 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 354, ;
Width = 100, ;
Name = "Text3"
ADD OBJECT text4 AS textbox WITH ;
Height = 20, ;
Left = 72, ;
Top = 375, ;
Width = 100, ;
Name = "Text4"
ADD OBJECT label5 AS label WITH ;
Caption = "当前X:", ;
Height = 16, ;
Left = 240, ;
Top = 310, ;
Width = 38, ;
Name = "Label5"
ADD OBJECT label6 AS label WITH ;
Caption = "当前Y:", ;
Height = 16, ;
Left = 240, ;
Top = 340, ;
Width = 38, ;
Name = "Label6"
ADD OBJECT text5 AS textbox WITH ;
Height = 20, ;
Left = 290, ;
Top = 310, ;
Width = 100, ;
Name = "Text5"
ADD OBJECT text6 AS textbox WITH ;
Height = 20, ;
Left = 290, ;
Top = 340, ;
Width = 100, ;
Name = "Text6"
ADD OBJECT text7 AS textbox WITH ;
Height = 31, ;
Left = 290, ;
Top = 370, ;
Width = 151, ;
Name = "Text7"
ADD OBJECT text8 AS textbox WITH ;
Height = 20, ;
Left = 490, ;
Top = 340, ;
Width = 100, ;
Name = "Text8"
ADD OBJECT text9 AS textbox WITH ;
Height = 20, ;
Left = 490, ;
Top = 370, ;
Width = 100, ;
Name = "Text9"
PROCEDURE MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.text8.Value=nxcoord
thisform.text9.Value=nycoord
ENDPROC
PROCEDURE grid1.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
LOCAL nXCoord, nYCoord, nWhere_Out, nRow_Out, nCol_Out, nView_Out
nwhere_out=0
nrow_out=0
ncol_out=0
nview_out=0
tf=this.GridHitTest(nXCoord, nYCoord, @nWhere_Out, @nRow_Out, @nCol_Out, @nView_Out)
IF tf=.t.
thisform.text1.Value=nwhere_out
thisform.text2.Value=nrow_out
thisform.text3.Value=ncol_out
thisform.text4.Value=nview_out
ENDIF
thisform.text5.Value=nxcoord
thisform.text6.Value=nycoord
thisform.CurrentX=nxcoord
thisform.CurrentY=nycoord
ENDPROC
PROCEDURE grid1.Init
temptable=SYS(2015)
CREATE TABLE &temptable FREE (颜色 c(30), XS N(5),S N(5),M N(5),L N(5),XL N(5),XXL N(5),TOTAL n(6))
this.RecordMark=.t.
this.DeleteMark=.f.
this.SetAll('alignment',2,'header')
this.headerheight=35
this.RowHeight=25
this.recordsource=temptable
this.AllowAddNew=.t.
APPEND BLANK
ENDPROC
PROCEDURE grid1.Click
nxcoord=thisform.CurrentX
nycoord=thisform.CurrentY
STORE 0 TO nwhere_out,nrow_out,ncol_out,nview_out
isclicked=this.GridHitTest(nXCoord, nYCoord, @nWhere_Out, @nRow_Out, @nCol_Out, @nView_Out)
IF isclicked
thisform.text1.Value=nwhere_out
ENDIF
ENDPROC
PROCEDURE text7.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
*NODEFAULT
thisform.text8.Value=nxcoord
thisform.text9.Value=nycoord
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************