|
-
April 1st, 1999, 08:14 AM
#1
Changing Default Font in a Dialog
I have a dialog based application that is used by users with various screen
resolutions. I use a default font set up in the resource editor
(10 pt. MS Sans Serif). This works fine on the higher resolution screens but in
800x600 it is too big to fit on the screen. If I use an 8 pt. font, it looks
better in low res but is too small in high res. I have been trying to change the
font on the fly by using the following code in the OnInitDialog;
d_dfont = GetFont();
d_dfont->GetLogFont(&d_lf);
d_dfont = new CFont();
d_lf.lfHeight -= 2;
d_dfont->CreateFontIndirect(&d_lf);
SetFont(d_dfont);
CClientDC dc(this);
dc.SelectObject(d_dfont);
This has no apparent affect. I have tried the same thing in the OnSetFont and
OnPaint functions also to no avail. What I want to do is to test the screen
resolution and then set the default font before displaying the dialog. Does
anyone know how this can be done?
-
April 1st, 1999, 10:26 AM
#2
Re: Changing Default Font in a Dialog
You can use GetSystemMetrics with SM_CXFULLSCREEN, SM_CYFULLSCREEN to get the size of the screen (I think). As for changing the font, I did something similar for a 16 bit app once, and ended up enumerating all the child windows of the dialog and explicitly setting the font of each. I did this from OnInitDialog, and it worked fine, but whether it's a good way to do it...
-
April 1st, 1999, 11:14 AM
#3
Re: Changing Default Font in a Dialog
You are right, I have used GetSystemMetrics to determine the screen resolution.
However, I was hoping to avoid having to resize each control individually. It
seems like I should be able to set the default font before the dialog is
displayed and have everything re-size itself accordingly (or is this something
that only happens in the Resource Editor?).
-
April 1st, 1999, 02:00 PM
#4
Re: Changing Default Font in a Dialog
what about OnCtlColour(), I don't remember exactly , I have changed the color and I think even the font also. I am pretty sure because I remember I was putting a font dialog selecting the font and size and then displaying the text in that font(something similar to word art). invalidate() must call the OnCtlColor(), if you have to do it intermittent in your code. Note that it has got a CDC as an argument.
Good Luck
-
August 3rd, 1999, 12:34 PM
#5
Re: Changing Default Font in a Dialog
Hello:
My name is Rick Ullett, and I work at the Dayton Power and Light Company. I came across your question regarding re-sizing the point size for a dialog box. Reading your question was like taking the words right out of my mouth.
My attempt to do this in code was also virtually the same as the unsuccessful attempt you listed.
Did you ever find a clean way to do this? The code guru repsonses didn't look that promising.
If you get a chance, I'd sure like to know what you found out.
Thanks in advance,
Rick
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
|