setting button caption font
I've got a button like this:
Code:
CreateWindowEx(0,
"BUTTON",
"generuj",
WS_CHILD | WS_VISIBLE,
55,
270,
80,
20,
hWnd,
(HMENU)1,
g_hInstance,
NULL);
and a font like this:
Code:
HFONT fontArial=CreateFont(16,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, DEFAULT_PITCH,"arial");
Can anybody tell me how to set this button's caption font to this 'fontArial'? I'm am a newbie to win32.
Re: setting button caption font
Use the WM_SETFONT message.
--FCOD
Re: setting button caption font
Re: setting button caption font
Look up the WM_SETFONT message in the MSDN.
http://msdn.microsoft.com/library/de...wm_setfont.asp
--FCOD
edit: Don't post your question in more than one forum...it's against the rules and bad etiquette.
Re: setting button caption font
ok i get it, and used it already thanks. But I have a few 'windows', and do I ahve to send a message like this to each one? Is there a method using which I could change all the 'window's' fonts at once? I've got this type of situation:
PHP Code:
SendMessage(hDlgItem1, WM_SETFONT, (WPARAM)fontArial, TRUE);
SendMessage(hDlgItem4, WM_SETFONT, (WPARAM)fontArial, TRUE);
SendMessage(hDlgItem5, WM_SETFONT, (WPARAM)fontArial, TRUE);
SendMessage(hDlgItem6, WM_SETFONT, (WPARAM)fontArial, TRUE);
SendMessage(hDlgItem9, WM_SETFONT, (WPARAM)fontArial, TRUE);
SendMessage(hDlgItem8, WM_SETFONT, (WPARAM)fontCourier, TRUE);
SendMessage(hDlgItem7, WM_SETFONT, (WPARAM)fontCourier, TRUE);
SendMessage(hDlgItem3, WM_SETFONT, (WPARAM)fontCourier, TRUE);
SendMessage(hDlgItem2, WM_SETFONT, (WPARAM)fontCourier, TRUE);
and I would like to send only 2 messages: to those which use fontCourier and to the fontArial ones.
Re: setting button caption font
You should not cross posts in different forums.
You get an answer in one, while other people try to help you in another without knowing that your problem has been resolved; they could use that time to help others.
To answer your question about sending messages, unfortunately there is no way of doing it different way unless buttons have consecutive ID that you would be able to use in a loop.
Re: setting button caption font
Other options to get child windows are:
- You could use EnumChildWindows to enumerate through all child windows of a parent window
- You could use GetWindow API to navigate through child windows ( GWL_HWNDNEXT/PREV)
If you want to do it for buttons only, you may want to check for the class name of the window and then take action appropriately.