Rick Ullett
September 9th, 1999, 07:07 AM
This question has been posted at least three times
(including one from me earlier) since I've been participating in the forum. But,... I haven't as
of yet seen a successful response. I promise to
try all suggested solutions and respond with a comment on the success or failure.
I know this is the same question posted earlier, but it didn't ever get a satisfactory solution.
I did try to do a similar approach to the one listed below in an override of the OnPaint funtion, as suggested to me in my earlier posting.
As I replied to that attempt, it "seems" like it should work - it just doesn't. (Please see my
response posted 8/31/99 on this issue for my
attempt on the OnPaint override.)
So, I'll try again:
I have a SDI application that is used by users with various screen resolutions. I use a default font set up in the resource editor for many dialog boxes used by the task.
(EX: 10 pt. MS Sans Serif). This works fine on the higher resolution screens but in 800x600 or 640x480 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 OnSetFont:
LOGFONT d_lf;
CFont newFont;
BOOL font_ok;
// Pick up the existing dialog font
pfont -> GetObject(sizeof(d_lf),&d_lf);
// Change the font size
d_lf.lfHeight = -13;
// Create a new font with the new height
font_ok = newFont.CreateFontIndirect(&d_lf);
// Call the standard OnSetFont with the newly
// created font.
CDialog::OnSetFont(&newFont);
This has no apparent affect. I have tried the same thing in the OnInitDialog function also to no avail. I have also played with the value for the new height, or switching to a new font family , but again without success. What I want to do is to set the default font before displaying the dialog box. Does anyone know how this can be done?
I do not want to adjust the size of each control in a dialog individually. I also don't want to create "copies" of the same dialog at various point sizes. These alternatives make the code too ugly, and difficult to support.
Thanks in advance to anyone who can help.
(including one from me earlier) since I've been participating in the forum. But,... I haven't as
of yet seen a successful response. I promise to
try all suggested solutions and respond with a comment on the success or failure.
I know this is the same question posted earlier, but it didn't ever get a satisfactory solution.
I did try to do a similar approach to the one listed below in an override of the OnPaint funtion, as suggested to me in my earlier posting.
As I replied to that attempt, it "seems" like it should work - it just doesn't. (Please see my
response posted 8/31/99 on this issue for my
attempt on the OnPaint override.)
So, I'll try again:
I have a SDI application that is used by users with various screen resolutions. I use a default font set up in the resource editor for many dialog boxes used by the task.
(EX: 10 pt. MS Sans Serif). This works fine on the higher resolution screens but in 800x600 or 640x480 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 OnSetFont:
LOGFONT d_lf;
CFont newFont;
BOOL font_ok;
// Pick up the existing dialog font
pfont -> GetObject(sizeof(d_lf),&d_lf);
// Change the font size
d_lf.lfHeight = -13;
// Create a new font with the new height
font_ok = newFont.CreateFontIndirect(&d_lf);
// Call the standard OnSetFont with the newly
// created font.
CDialog::OnSetFont(&newFont);
This has no apparent affect. I have tried the same thing in the OnInitDialog function also to no avail. I have also played with the value for the new height, or switching to a new font family , but again without success. What I want to do is to set the default font before displaying the dialog box. Does anyone know how this can be done?
I do not want to adjust the size of each control in a dialog individually. I also don't want to create "copies" of the same dialog at various point sizes. These alternatives make the code too ugly, and difficult to support.
Thanks in advance to anyone who can help.