Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use GetTextExtentPoint32
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00829574
Message ID:
00829600
Vues:
25
This code works:
DECLARE INTEGER GetTextExtentPoint32 IN gdi32;
	INTEGER hdc, STRING lpString,;
	INTEGER cbString, STRING @lpSize

DECLARE INTEGER GetActiveWindow IN user32
DECLARE INTEGER GetWindowDC IN user32 INTEGER hWnd
DECLARE INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER hdc

LOCAL hWindow, hDC, cString, nX, nY, cBuffer
hWindow = GetActiveWindow()
hDC = GetWindowDC(hWindow)
cString = 'How to use GetTextExtentPoint32'
STORE 0 TO nX, nY
cBuffer = Repli(Chr(0), 8)

= GetTextExtentPoint32(hDC, cString, Len(cString), @cBuffer)
? buf2dword(SUBSTR(cBuffer, 1,4))
? buf2dword(SUBSTR(cBuffer, 5,4))
	
= ReleaseDC(hWindow, hDC)

FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
	BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
	BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
	BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
It looks like you missed that last parameter in GetTextExtentPoint32 should be passed as a reference. That's why it stays unchanged when API call returns.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform