Page 1 of 1
GetWindowTextHeight() / GetWindowTextWidth()
Posted: Thu Nov 26, 2020 12:25 pm
by AUGE_OHR
hi,
does someone can show me a working Sample
Code: Select all
nPixelX := GetWindowTextWidth(Form_1.HANDLE, "hello world")
but it does not give me different Result when change Font of Form_1

Re: GetWindowTextHeight() / GetWindowTextWidth()
Posted: Thu Nov 26, 2020 2:03 pm
by bpd2000
Re: GetWindowTextHeight() / GetWindowTextWidth()
Posted: Thu Nov 26, 2020 5:04 pm
by mol
LOCAL hDC, BTstruct
hDC := BT_CreateDC (Form1, BT_HDC_INVALIDCLIENTAREA, @BTstruct)
w := BT_DrawTextSize(hDC,"hello world!", "ARIAL", 9, BT_TEXT_BOLD + BT_TEXT_ITALIC)
Re: GetWindowTextHeight() / GetWindowTextWidth()
Posted: Fri Nov 27, 2020 5:28 am
by AUGE_OHR
hi,
thx for Answer
have understand that i need hFont ( have not test _HMG_SYSDATA [ 36 ] or _HMG_SYSDATA [ 28 ] )
so i create Font
Code: Select all
FUNCTION DoGetFontHeight(cText)
LOCAL hWnd := Form_1.HANDLE
LOCAL hDC := GetDC(Form_1.HANDLE)
LOCAL hFont := HMG_CreateFont ( hDC , SP_cFontName(), SP_nFontSize(), .F., .F., .F., .F. )
LOCAL nPixelY
nPixelY := GetTextHeight( hDC, cText, hFont )
ReleaseDC( hWnd, hDC )
DeleteObject (hFont)
RETURN nPixelY
same i use for GetTextWidth()
Code: Select all
nPixelX := GetTextWidth( hDC, cText, hFont )
but i have to "add" some Pixel ( 0.072/72*25.4*nPixelX*SP_nFontSize() )
thx for help