Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the LOGFONT structure from a HFONT handle? [duplicate]

Tags:

c++

fonts

winapi

If I have the handle of a window, say hWnd, I can get the handle to its font type, say hFont, like this:

HFONT hFont = SendMessage(hWnd, WM_GETFONT, NULL, NULL);

After this point, how do I obtain a LOGFONT structure (which contains many features of the font), from this HFONT handle?

My purpose is not to create a font from scratch by calling CreateFont(). I want to read font properties into a LOGFONT structure, then arbitrarily modify it, and finally update the font by calling the CreateFontIndirect() function and passing the modified LOGFONT object to it.

How do I do this?

like image 344
hkBattousai Avatar asked Oct 14 '25 14:10

hkBattousai


1 Answers

You are looking for GetObject.

like image 119
Igor Tandetnik Avatar answered Oct 17 '25 04:10

Igor Tandetnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!