Click to See Complete Forum and Search --> : setting button caption font
zombek
October 14th, 2005, 09:51 AM
I've got a button like this:
CreateWindowEx(0,
"BUTTON",
"generuj",
WS_CHILD | WS_VISIBLE,
55,
270,
80,
20,
hWnd,
(HMENU)1,
g_hInstance,
NULL);
and a font like this:
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.
flyingcowofdoom
October 14th, 2005, 10:25 AM
Use the WM_SETFONT message.
--FCOD
zombek
October 14th, 2005, 10:32 AM
but how?
flyingcowofdoom
October 14th, 2005, 10:36 AM
Look up the WM_SETFONT message in the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_setfont.asp
--FCOD
edit: Don't post your question in more than one forum...it's against the rules and bad etiquette.
zombek
October 15th, 2005, 02:57 AM
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:
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.
JohnCz
October 17th, 2005, 10:12 PM
You should not cross posts in different forums (http://www.codeguru.com/forum/showthread.php?t=360987).
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.
kirants
October 19th, 2005, 07:35 PM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.