LPARAMETERS data, effect, button, shift, x, y, state loNode = This.HitTest(X * This.nTreeFactorX, Y * This.nTreeFactorY) if vartype(loNode) = 'O' loNode.Selected = .T. endifnTreeFactorX and nTreeFactorY are custom properties that handle the conversion of twips (the unit used by the TreeView) to pixels (the units used by VFP). Here's the code, usually placed in Init, that sets these properties:
local liHWnd, ; liHDC, ; liPixelsPerInchX, ; liPixelsPerInchY * Define some constants. #define cnLOG_PIXELS_X 88 * From WINGDI.H #define cnLOG_PIXELS_Y 90 * From WINGDI.H #define cnTWIPS_PER_INCH 1440 * 1440 twips per inch * Declare some Windows API functions. declare integer GetActiveWindow in WIN32API declare integer GetDC in WIN32API ; integer iHDC declare integer GetDeviceCaps in WIN32API ; integer iHDC, integer iIndex * Get a device context for VFP. liHWnd = GetActiveWindow() 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 endwithIn OLECompleteDrag, which fires when the drag ends, This.SelectedItem is a reference to the node the user dropped the item on.