lparameters tnButton, ; tnShift, ; tnXCoord, ; tnYCoord #DEFINE BUTTON_LEFT 1 #DEFINE DRAG_MANUAL 0 && 0 - Manual #DEFINE DRAG_AUTOMATIC 1 && 1 - Automatic local loNode with This * Ensure the node under the mouse is selected. loNode = .HitTest(tnXCoord * Thisform.nTreeFactorX, ; tnYCoord * Thisform.nTreeFactorY) if not isnull(loNode) .NodeClick(loNode) endif not isnull(loNode) * If this is the left mouse button, determine whether we can drag from the * selected node or not. if tnButton = BUTTON_LEFT .OLEDragMode = iif(.CanStartDrag(), DRAG_AUTOMATIC, DRAG_MANUAL) endif tnButton = BUTTON_LEFT endwithThe nTreeFactorX and nTreeFactorY properties used in this code are set in the following code (called from Init):
* Calculate the conversion factor between VFP window units (in pixels) and * TreeView window units (in twips). #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, ReleaseDCDoug