Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TreeView.HitTest returns invalid reference
Message
From
03/03/2004 04:07:30
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00882283
Message ID:
00882618
Views:
39
>In your app startup you would need code similar to this:
>
declare integer GetActiveWindow in WIN32API
>declare integer GetDC in WIN32API integer iHDC
>declare integer GetDeviceCaps in WIN32API integer iHDC,integer iIndex
>* Device context
>liHwnd=GetActiveWindow()
>liHDC=GetDC(liHwnd)
>* Pixels per Inch
>liPixelsPerInchX=GetDeviceCaps(liHDC,88)
>liPixelsPerInchY=GetDeviceCaps(liHDC,90)
>* Twips per pixel and store
>unLTVX=1440/liPixelsPerInchX
>unLTVY=1440/liPixelsPerInchY
>
>* In the treeviews mouse move you would need something like
>
procedure MouseMove(button, shift, x, y)
>IF thisform.chkHotTracker.Value
>   oNode=this.HitTest(X*unLTVX,Y*unltvY)
>   if type('oNode.text')==[C]
>      this.NodeClick(oNode)
>   else
>   ENDIF
>ELSE
>ENDIF
>ENDPROC
>
>You need to assure the node exists {if type('oNode.text')==[C]}, before you treat it like one:)
>
>There is a demo of this in download #16575
>


Hi Terry,

Many thanks for a different perspective. Here's what I've encountered (or didn't expect to).

First, I stored unLTVX & unLTVY in form's properties and they appear to be
both 15 in my case.

Secondly, when the mouse moves in excess of about 40 pixels in either dimension (x or y), the entire instance of VFP crashes. It appears that the HitTest() method cannot take arguments with values larger than ~ 40*15.

Thirdly, nowhere between the 0-39 pixel region do I get any positive results, as in ...
oNode=THIS.HitTest(X*THISFORM.unLTVX,Y*THISFORM.unLTVY)
IF TYPE('oNode.text')==[C]   && TYPE('oNode.text') is 'U'
   messagebox('Got It!')     && just did not get it
ENDIF
Fourthly, I moved the HitTest code out of the MouseMove event and put it in a commandbutton, with the MouseMove event only storing the {x,y} co-ords in form's properties, and something even more peculiar happens. If the {x,y} values are within limit the 1st time around, then subsequent calls to HitTest() with very large values (e.g. 250*15,350*15) does not crash the app.
*  MouseMove ...
THISFORM.liX = x
THISFORM.liY = y
*  CommandButton1 ...
LOCAL oNode
oNode = THISFORM.tvPPP.OBJECT.HitTest(THISFORM.liX*THISFORM.unLTVX,THISFORM.liY*THISFORM.unLTVY)
* or oNode = THISFORM.tvPPP.HitTest(THISFORM.liX*THISFORM.unLTVX,THISFORM.liY*THISFORM.unLTVY)
I have tried this on 2 different machines, and the responses the same.

What shall I make of the TreeView control? Shall I write it off as a control still with MS's bugs and not worth attempting anything beyond what's simple and known to work? Or I'm just missing something here?
Kenneth.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform