Link to home
Start Free TrialLog in
Avatar of trillo
trillo

asked on

Fontsize in Static Ctrl

This must be very easy:

I have a dialog box with a Static control (Static Text). How do I change the font size?
I'm NOT USING MFC !!!

I can obtain a HFONT handle by sending the WM_GETFONT message to the control, and I could send it back with the WM_SETFONT message... but what should I do with that handle to change the font size?... Or am I the complete wrong way?
Thanks
Avatar of trillo
trillo

ASKER

Edited text of question.
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trillo

ASKER

Just what I needed!

I tried what you said and it worked, although my control uses the system font (Ms Sans Serif), and it seems that you can't get the font smaller than default. I could change de typeface in the LOGFONT structure, but how do I handle if that font does not exist in some other machine?

And, by the way, do you how do I change the color of the text in my static control?

Thanks.
Hi trillo,

If the specified font does not exist, the Windows font mapper selects a font which characteristics match the given LOGFONT as near as possible, so for most cases you don't have to worry about it. If you want to find out if a font exist you can use the EnumFontFamilies() API function.

To change the color of the text you'll have to handle the WM_CTLCOLOR message. With this message you recieve a device context handle which you can use to set the text color via SetTextColor(). See help for WM_CTLCOLOR for further infos.

hope that helps,

ZOPPO
Avatar of trillo

ASKER

Thanks a lot.