Archived

This topic is now archived and is closed to further replies.

Omalacon

Win32 API: easy yet not....

Recommended Posts

I thought I would brush up on my Win32 API skills, I HATE MFC, and am actually wanting to write a couple of actual applications that don''t use DirectX. (I only know enough of the platform sdk to get me into directx and load bitmaps). Here is the problem, Just for starters I create an overlappedwindow then create a child button. (I know dialogboxes are easier than manually drawing a button, but I am trying to learn as much as possible). I hated the standard font used for the button, so I switch it to MS Sans Serif. Switching the font was easy enough, but I have to set the font every time the os wants to draw the button (WM_CTLCOLORBTN message is sent to the parent window). It seems very inefficient having to tell the OS what font to use every single time (yes I know efficient and windows doesn''t exactly match very well). Is there a way to set the font and just have windows remember, rather than having to create the font handle then select it every single time??? Thanks, Omalacon

Share this post


Link to post
Share on other sites
Windows aren''t the smartest little things, but they''ll do whatever you tell ''em (better than most programs we know of).

=======================================
A man with no head is still a man.
A head with no man is plain freaky.

Share this post


Link to post
Share on other sites
WM_SETFONT

(hehe you just had to ask...)

Just use CreateFont() to create the font before you create the button, and use DeleteObject() to destroy it. Send the button a WM_SETFONT message with your font handle in its WM_CREATE handler. The MSDN docs give a great example on this.





- null_pointer
Sabre Multimedia

Share this post


Link to post
Share on other sites
Thanks it worked, forgot there were messages meant for you to send rather than windows. I found out about the WM_CTLCOLORBTN message using spy++. Had no idea of the the WM_SETFONT message. Even went through the help docs trying to find a message dealing with fonts, guess I missed it

-Omalacon

Share this post


Link to post
Share on other sites