Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Treeview problem
Message
From
08/11/2006 12:35:32
 
 
To
08/11/2006 09:24:39
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Germany
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MySQL
Miscellaneous
Thread ID:
01167992
Message ID:
01168113
Views:
20
You have to detect the right-click in the MouseDown event:
LPARAMETERS pnButton, pnShift, pnX, pnY
LOCAL loNode
IF pnButton = 2
	loNode = this.HitTest(PixelsToTwips(pnX,"H"),PixelsToTwips(pnY,"V"))
	IF VARTYPE(loNode) = "O"
		thisform.TVRightCkMenu(loNode)
	ENDIF
ENDIF
In the above code, PixelsToTwips is a custom function and TVRightCkMenu is a custom method for displaying the right-click menu.

The code for PixelsToTwips is as follows:
************************************************************************************************
* Based on Microsoft Knowledge Base Articles 94927, 210590
*
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL 
* IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE ARE HEREBY DISCLAIMED.
*
************************************************************************************************
* Function to Convert from Pixels to Twips
*
* Parameters:  
*     pnPixels       Value to convert to twips
*     pcDirection    Screen direction; 'H' for horizontal and 'V' for vertical
*
* Returns:
*     Twips value
*
*FUNCTION PixelsToTwips
LPARAMETERS pnPixels, pcDirection
LOCAL lhDeviceHdl, lnPixelsPerInch
#DEFINE LOGPIXELSX  88
#DEFINE LOGPIXELSY  90
DECLARE LONG GetDeviceCaps IN "gdi32"  LONG hdc,  LONG nIndex
DECLARE LONG ReleaseDC     IN "user32" LONG hwnd, LONG hdc
DECLARE LONG GetDC         IN "user32" LONG hwnd
lhDeviceHdl = GetDC(0)
DO CASE
	CASE pcDirection = "H"        && Horizontal
		lnPixelsPerInch = GetDeviceCaps(lhDeviceHdl,LOGPIXELSX)
	CASE pcDirection = "V"        && Vertical
		lnPixelsPerInch = GetDeviceCaps(lhDeviceHdl,LOGPIXELSY)
ENDCASE
lhDeviceHdl = ReleaseDC(0,lhDeviceHdl)
RETURN pnPixels * 1440 / lnPixelsPerInch
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform