Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HitTest he returns wrong reference
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00685241
Message ID:
00685247
Vues:
9
This message has been marked as the solution to the initial question of the thread.
>I try to use HitTest method in order to get ListItem object located at the coordinates of x and y. But HitTest method returns a reference to the wrong ListItem object. Any ideas?
>
>Thanks

You're probably trying to pass it the coordinates directly. HitTest is expecting the coordinates in Twips, not pixels. Take a look at www.stonefield.com. In the technical papers section there is a white paper on ActiveX controls. Doug has a routine to convert pixels to twips. Most GDI interfaces have twips defined as 15 twips per pixel, so you COULD just take x*15 for the result. However, you're much better off using Dougs code because it will always return the correct conversion factor for you. Actually, I think I've got the code right here....
* Code you can add to the Init() section of your form
* Make sure you create two properties: nXMultiplier and nYMultiplier

ThisForm.nXMultiplier = 1440/_GetPixelsPerInch(0) 
ThisForm.nYMultiplier = 1440/_GetPixelsPerInch(1) 

* Then in the MouseDown() you can do a HitTest: 

loNode = This.HitTest(x * ThisForm.nXMultiplier, y * ThisForm.nYMultiplier) 

FUNCTION _GetPixelsPerInch 
LPARAMETERS lnDirection 
DECLARE INTEGER ReleaseDC IN Win32Api; 
        INTEGER nwnd, INTEGER hdc 
DECLARE INTEGER GetDeviceCaps IN Win32API; 
        INTEGER hdc, INTEGER nIndex 
DECLARE INTEGER GetWindowDC IN Win32API; 
        INTEGER hWnd 

#DEFINE WU_LOGPIXELSX  88 
#DEFINE WU_LOGPIXELSY 90 

lnDC = GetWindowDC(0) 

IF (lnDirection = 0)       &&Horizontal 
        lnPixelsPerInch = GetDeviceCaps(lnDC, WU_LOGPIXELSX) 
ELSE                       &&Vertical 
        lnPixelsPerInch = GetDeviceCaps(lnDC, WU_LOGPIXELSY) 
ENDIF 

lnDC = ReleaseDC(0, lnDC) 

RETURN lnPixelsPerInch 
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform