|
-
Sep 16th, 2001, 09:53 PM
#1
Thread Starter
Fanatic Member
Font
The Fonts are always ugly... How do you change them? In Win32 that is...

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 16th, 2001, 09:55 PM
#2
Frenzied Member
may I offer parksies famous funcion
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, (WPARAM)hTheFont, TRUE);
}
-
Sep 17th, 2001, 11:41 AM
#3
Monday Morning Lunatic
No, you may not 
Kidding, use it all you want! It's free!
(like Simon's mum on thursday nights )
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
-
Sep 18th, 2001, 08:44 AM
#4
If you don't want to set the font of controls, you'll need a device context too. Just replace the line with SendMessage by:
Code:
HFONT hOldFont = SelectObject(hdc, hfont);
Then return the old font (you will have to select it back into the dc once your done drawing text). Unlike parksies function, you must call this every time you got a new dc. (BeginPaint, GetDC etc.)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 14th, 2003, 06:25 AM
#5
Addicted Member
One VERY important rule to remember is not to destroy the font after sending WM_SETFONT message. Windows will not make a copy of the font and starangethings can happen if an HFONT is destroyed while it is being refferenced.
Who needs rhetorical questions anyway?
Bazza NET - The place you want to be!

-
May 14th, 2003, 06:51 AM
#6
Someone's been browsing posts... (look at the date)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|