changing the font of a win32 window and its child windows and controls
Posted on 2004-03-22
Hi. I have a win32 window in my app created using CreateWindowEx. It is not a dialog and I am not using MFC. I want to be able to change the font of this window as well as all of its child windows and any controls that it has. I have read that you should be able to do this by creating your font using CreateFont, storing the result as an HFONT. Then send a WM_SETFONT message to the window. eg.
SendMessage(m_hWnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
where hFont is the desired font. However this seems to do nothing. I call this code after I have created the main window but before any children or controls have been created. If I call:
Then that seems to set the font for the device context of the window without a problem as I can do a TextOut inside the WM_PAINT message catch and text is written correctly in the desired format. I really want to get this sorted as I hate the bold font used by default with win32 controls etc. Thanks for any help.