|
-
Apr 26th, 2001, 11:46 AM
#1
Thread Starter
Frenzied Member
Fonts
How would I add different fonts to my buttons and statics?
-
Apr 26th, 2001, 12:22 PM
#2
Monday Morning Lunatic
You need to send it a WM_SETFONT message with the handle to a newly created HFONT:
Code:
SendMessage(hWnd_Edit, WM_SETFONT, hTheFont, TRUE); // TRUE = redraw after setting
To create the font, use the CreateFont function:
Code:
HFONT hTheFont;
HDC hEditDC = GetDC(hWnd_Edit);
int nHeight = -MulDiv(26 /* Point size required */, GetDeviceCaps(hEditDC, LOGPIXELSY), 72);
hTheFont = CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Times New Roman");
ReleaseDC(hEditDC);
See the PSDK for more info on the parameters...there's lots of them I would post it here but it's too long
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 26th, 2001, 12:41 PM
#3
Thread Starter
Frenzied Member
should I put this right under WinMain?
so It would look like this?
Code:
HFONT hTheFont;
HDC hEditDC = GetDC(ghWnd_PlayFile);
int nHeight = -MulDiv(26 /* Point size required */, GetDeviceCaps(hEditDC, LOGPIXELSY), 72);
hTheFont = CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Wingdings 3");
ReleaseDC(ghWnd_PlayFile, hEditDC);
SendMessage(ghWnd_PlayFile, WM_SETFONT, hTheFont, TRUE); // TRUE = redraw after setting
-
Apr 26th, 2001, 12:46 PM
#4
Monday Morning Lunatic
You could do, or you could separate it out into a separate function that you call from WinMain:
Code:
void SetFont(HWND hWnd, int iPointSize, const char *pcFontName) {
HFONT hTheFont;
HDC hDC = GetDC(hWnd);
int nHeight = -MulDiv(iPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
hTheFont = CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, pcFontName);
ReleaseDC(hWnd, hDC);
SendMessage(hWnd, WM_SETFONT, hTheFont, TRUE);
}
int WinMain(...) {
// ...
SetFont(ghWnd_Edit, 26, "Wingdings 3");
// ...
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 26th, 2001, 01:03 PM
#5
Thread Starter
Frenzied Member
Nothing Changes...not even sizes
-
Apr 26th, 2001, 01:23 PM
#6
Monday Morning Lunatic
Hmmm...it worked for me when I just tested that function 
(I used the (WPARAM) cast as decided in our MSN conversation...)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|