Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use GetTextExtentPoint32
Message
De
16/09/2003 15:01:02
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How to use GetTextExtentPoint32
Divers
Thread ID:
00829574
Message ID:
00829574
Vues:
113
Hi Everyone.

I'm trying to calculate the length of a string and TXTWIDTH does things in foxels rather than pixels, which is ugly. So, I'm trying to use the GetTextExtentPoint32 API function. Here's the code I'm using:
declare long GetTextExtentPoint32 in Win32API long hdc, ;
  string @ cString, long nSize, string @ cSize
declare integer GetDC in Win32API integer hwnd 
declare integer ReleaseDC in Win32API integer hwnd 

loForm = createobject('Form')
loForm.FontName = 'Arial'
loForm.FontSize = 10
lnHWnd   = loForm.HWnd
lnHDC    = GetDC(lnHWnd)
lcSize   = replicate(chr(0), 8)
lcString = '$99,999,999.99'
lnLen    = len(lcString)
lnReturn = GetTextExtentPoint32(lnHDC, lcString, lnLen, lcSize)
* Get the text height and width from lcSize
ReleaseDC(lnHDC)
However, while GetTextExtentPoint32 returns a successful value (1), lcSize doesn't contain the proper size (it's still 8 CHR(0)).

Any ideas about the correct way to use this function in VFP? TIA

Doug
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform