Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drag and drop in treeviews
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01356825
Message ID:
01357076
Vues:
58
Hallo Doug!
Thankyou for your answer. It took a while before I understood everything, but now I think I know how it works.
But I have a problem with the HitTest method. I allways get a logic .T. back, never a nodereference.
I have tried to use the HitTest method before, and it doesnt matter what value there is on X and Y, I allways get a .T. in return. (Maybe I have got a .F. back sometime, but never a nodereference.
I dont know what is wrong.
/Kell


>Hi Kjell.
>
>>But if node 1 is highlighted and I press the mousebutton over an other node, lets say node 3, without releasing the button, and make a "drag and drop", I can NOT use the information in treelist.selecteditem, because the information is still related to node 1. I must release the button over node 3 so the information in "selecteditem" can change to node 3.
>
>The TreeView control does not automatically select a node when the use clicks the mouse but does not release the mouse button. In that case, you should use the TreeView's HitTest method to determine which node is being dragged. HitTest expects you to pass it the X and Y coordinates of the mouse, but those values must be in twips (1/1440th of an inch) rather than pixels. So, first you have to know how to converts twips to pixels and pixels to twips. Here is code that determines how to do that (it assumes there are nTreeFactorX and nTreeFactorY properties of the class this method code is in):
>
#define cnLOG_PIXELS_X  88
>#define cnLOG_PIXELS_Y  90
>#define cnTWIPS_PER_INCH  1440
>
>local liHWnd, ;
>  liHDC, ;
>  liPixelsPerInchX, ;
>  liPixelsPerInchY
>
>* Declare some Windows API functions.
>
>declare integer GetDC in Win32API ;
>  integer iHDC
>declare integer GetDeviceCaps in Win32API ;
>  integer iHDC, integer iIndex
>declare integer ReleaseDC in Win32API ;
>  integer ihWnd, integer iHDC
>
>* Get a device context for VFP.
>
>liHWnd = _vfp.hWnd
>liHDC  = GetDC(liHWnd)
>
>* Get the pixels per inch.
>
>liPixelsPerInchX = GetDeviceCaps(liHDC, cnLOG_PIXELS_X)
>liPixelsPerInchY = GetDeviceCaps(liHDC, cnLOG_PIXELS_Y)
>
>* Get the twips per pixel.
>
>with This
>  .nTreeFactorX = cnTWIPS_PER_INCH/liPixelsPerInchX
>  .nTreeFactorY = cnTWIPS_PER_INCH/liPixelsPerInchY
>endwith
>
>* Clean up.
>
>ReleaseDC(liHWnd, liHDC)
>clear dlls GetDC, GetDeviceCaps, ReleaseDC
Now in the TreeView's MouseDown method, you can do something like this:
>
loNode = This.HitTest(nXCoord * Thisform.nTreeFactorX, ;
>  nYCoord * Thisform.nTreeFactorY)
>* do something with loNode, such as storing it in a property
Doug
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform