GetWindowTextHeight() / GetWindowTextWidth()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

GetWindowTextHeight() / GetWindowTextWidth()

Post 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 :(
have fun
Jimmy
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: GetWindowTextHeight() / GetWindowTextWidth()

Post by bpd2000 »

This discussion may be useful to you
http://hmgforum.com/viewtopic.php?f=5&t=3872
BPD
Convert Dream into Reality through HMG
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: GetWindowTextHeight() / GetWindowTextWidth()

Post 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)
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: GetWindowTextHeight() / GetWindowTextWidth()

Post 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
have fun
Jimmy
Post Reply