Default font in dialog property pages

Have to post this again as all attempts to resolve the issue on my own were 
unsuccessful. 
The problem is, despite a property page template of a property sheet 
explicitly indicates that another font than the default MS Sans Serif  8 must 
be used (e.g. Arial 10), this never comes into effect. 
I checked the resource file to ensure that appropriate instructions are 
presented in there:

> > IDD_WIZ_PAGE0 DIALOG DISCARDABLE  0, 0, 235, 156
> > STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
> > CAPTION "Welcome to the Operation Wizard"
> > FONT 10, "Arial"
> > BEGIN 

Nevertheless, no matter which type and size of the font I specify in the 
template, the default font is always used. 
Although not expecting much, but being desperate to find a solution, I also 
tried to CFont and related member functions (e.g. CreateStockObject(), 
CreateFont(), etc.), but with no luck.

To my previous post with the same question, Jeff Partch [VC++ MVP] wrote:

>> Is this by any chance a page template for a propertysheet? IIRC, MFC
>> contains code to change the page template font to match the default font
>> used by the propertysheet (which is an internal OS resource). That may or
>> may not be what you're running into.

If that's the case, how do I change this "pre-defined" behaviour ?

Thanks in advance,
Andrew K.

0
andrewk1 (24)
2/7/2005 2:37:04 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
980 Views

Similar Articles

[PageSpeed] 19

You have not clarified what you have tried or what the effect is.

For example, if I want to change the font on a single control, I will create a CFont in
the control, or in the dialog, and use SetFont to set the font in the control, or for each
control of the dialog. This works; at least I've never seen it fail. Generally I need to
change the font only in a single control, so I've never tried to override the font has you
have done (and everything I know suggests that what you did should have worked, but I was
not aware of the problem Jeff posted). But given that I can override the font in a single
control, a simple for(CWnd * wnd = GetWindow(GW_CHILD); wnd != NULL; wnd =
GetWindow(GW_HWNDNEXT) type loop should allow you to set, individually, the font in every
window.  Create it in a CFont member variable of the dialog in OnInitDialog. Not elegant,
but it should work.
				joe

On Mon, 7 Feb 2005 06:37:04 -0800, Andrew K. <AndrewK@discussions.microsoft.com> wrote:

>Have to post this again as all attempts to resolve the issue on my own were 
>unsuccessful. 
>The problem is, despite a property page template of a property sheet 
>explicitly indicates that another font than the default MS Sans Serif  8 must 
>be used (e.g. Arial 10), this never comes into effect. 
>I checked the resource file to ensure that appropriate instructions are 
>presented in there:
>
>> > IDD_WIZ_PAGE0 DIALOG DISCARDABLE  0, 0, 235, 156
>> > STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
>> > CAPTION "Welcome to the Operation Wizard"
>> > FONT 10, "Arial"
>> > BEGIN 
>
>Nevertheless, no matter which type and size of the font I specify in the 
>template, the default font is always used. 
>Although not expecting much, but being desperate to find a solution, I also 
>tried to CFont and related member functions (e.g. CreateStockObject(), 
>CreateFont(), etc.), but with no luck.
>
>To my previous post with the same question, Jeff Partch [VC++ MVP] wrote:
>
>>> Is this by any chance a page template for a propertysheet? IIRC, MFC
>>> contains code to change the page template font to match the default font
>>> used by the propertysheet (which is an internal OS resource). That may or
>>> may not be what you're running into.
>
>If that's the case, how do I change this "pre-defined" behaviour ?
>
>Thanks in advance,
>Andrew K.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/7/2005 7:26:36 PM
Hi Joe, thank you for finding time to look into this. 

I just have a number of the Static Text controls in the welcoming page of 
the PropertySheet based wizard. And all I need is having them printed in 
something bigger than MS Sans Serif 8. Nothing relatively complex like 
dynamic controls changing at run-time and so on...  
Your response suggests me that each dialog control, even including static 
text ones, has to be treated as a separate window, or, in terms of MFC, a 
derivative of the CWnd class. Is my interpretation correct ?
Because so far, my understanding was that use of the resource editor to 
create the property page template with description of the required 
attributes, including font type and size, is sufficient, and I would not 
actually have to use CFont and SetFont() for this purpose.  

Thanks a lot,
Andrew



"Joseph M. Newcomer" wrote:

> You have not clarified what you have tried or what the effect is.
> 
> For example, if I want to change the font on a single control, I will create a CFont in
> the control, or in the dialog, and use SetFont to set the font in the control, or for each
> control of the dialog. This works; at least I've never seen it fail. Generally I need to
> change the font only in a single control, so I've never tried to override the font has you
> have done (and everything I know suggests that what you did should have worked, but I was
> not aware of the problem Jeff posted). But given that I can override the font in a single
> control, a simple for(CWnd * wnd = GetWindow(GW_CHILD); wnd != NULL; wnd =
> GetWindow(GW_HWNDNEXT) type loop should allow you to set, individually, the font in every
> window.  Create it in a CFont member variable of the dialog in OnInitDialog. Not elegant,
> but it should work.
> 				joe
> 
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 
0
andrewk1 (24)
2/7/2005 9:21:01 PM
Static text controls are the ones I most often change the font of; for example, to get
nice-looking headings (bold, large, centered types of headings). 

Each control IS a separate window, by definition. All are subclasses of CWnd, implicitly,
So nothing special here. My own choice is to create a subclass of CStatic. Sometimes I
build the font knowledge into it directly, e.g., use ClassWizard to create a new class
which is a subclass of CStatic, such as 

class CMyBigHeader : public CStatic {
       protected:
            CFont font;
};

then I just add the code to PreSubclassWindow to create the font and set it. All this
requires is assigning an ID other that IDC_STATIC to the control and creating a control
variable for it, no big deal.

I would have assumed that setting the font in the dialog editor would have done the job,
except for the observation that this apparently doesn't work for property pages.  Since I
usually need to change the font only for one or two controls, as I said, I never bothered
to change the overall font. 

By the way, what I usually do is create a font the height of the static control, so it
automatically adjusts for the scaling applied in various resolutions. Makes it a lot
safer.  So for example, in the PreSubclassWindow handler I would do

	CRect r;
	GetClientRect(&r);
	LOGFONT lf = {0};
	lf.lfHeight = r.Height();
	lf.lfWeight = FW_BOLD;
	lstrcpy(lf.lfFaceName, _T("Arial"));
	VERIFY(font.CreateFontIndirect(&lf));
	SetFont(&font);

sometimes I will subtract off a height such as an integer multiple of
::GetSystemMetrics(SM_CXBORDER) if I want it a bit smaller. This is usually the most
reliable method. You should not pick a fixed font height such as "10" because this will
invariably screw up on some high-resolution display (e.g., my new laptop does 1280x1024,
and it is amazing how many programs look really ugly because the programmers did not
program the dialogs as resolution-independent!)
					joe

On Mon, 7 Feb 2005 13:21:01 -0800, Andrew K. <AndrewK@discussions.microsoft.com> wrote:

>Hi Joe, thank you for finding time to look into this. 
>
>I just have a number of the Static Text controls in the welcoming page of 
>the PropertySheet based wizard. And all I need is having them printed in 
>something bigger than MS Sans Serif 8. Nothing relatively complex like 
>dynamic controls changing at run-time and so on...  
>Your response suggests me that each dialog control, even including static 
>text ones, has to be treated as a separate window, or, in terms of MFC, a 
>derivative of the CWnd class. Is my interpretation correct ?
>Because so far, my understanding was that use of the resource editor to 
>create the property page template with description of the required 
>attributes, including font type and size, is sufficient, and I would not 
>actually have to use CFont and SetFont() for this purpose.  
>
>Thanks a lot,
>Andrew
>
>
>
>"Joseph M. Newcomer" wrote:
>
>> You have not clarified what you have tried or what the effect is.
>> 
>> For example, if I want to change the font on a single control, I will create a CFont in
>> the control, or in the dialog, and use SetFont to set the font in the control, or for each
>> control of the dialog. This works; at least I've never seen it fail. Generally I need to
>> change the font only in a single control, so I've never tried to override the font has you
>> have done (and everything I know suggests that what you did should have worked, but I was
>> not aware of the problem Jeff posted). But given that I can override the font in a single
>> control, a simple for(CWnd * wnd = GetWindow(GW_CHILD); wnd != NULL; wnd =
>> GetWindow(GW_HWNDNEXT) type loop should allow you to set, individually, the font in every
>> window.  Create it in a CFont member variable of the dialog in OnInitDialog. Not elegant,
>> but it should work.
>> 				joe
>> 
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> 

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/7/2005 11:52:34 PM
Joe, you are the man !  Thanks to you, I now understand what's going on and 
can see the way-out of this somewhat stalemate (at least, for me) situation.

Million thanks for sharing your expertise and incredible willingness to help !

All the best,
Andrew.


0
andrewk1 (24)
2/8/2005 2:29:03 PM
That's what I'm here for...
				joe

On Tue, 8 Feb 2005 06:29:03 -0800, Andrew K. <AndrewK@discussions.microsoft.com> wrote:

>Joe, you are the man !  Thanks to you, I now understand what's going on and 
>can see the way-out of this somewhat stalemate (at least, for me) situation.
>
>Million thanks for sharing your expertise and incredible willingness to help !
>
>All the best,
>Andrew.
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/9/2005 11:53:47 PM
Reply:

Similar Artilces:

font in outlook
Hi, We have about 1000 users on our netwerk that have outlook 2003 installed in a terminalserver environment. I need to change the default font of all users in outlook. Does anyone know a way how to do this? All users have roaming profiles. Thx in advance, Ramon ...

Displaying Message from event sink to Edit control in dialog box
Hai I am working on FTP Software using MFC and i have to write the ftp server request and response to tracer window. The server request and response were caught by Eventsink and i donot know how to pass this text to edit control in dialog box which is another class. Here is coding of Event Sink / EventSink.cpp : implementation file // #include "stdafx.h" #include "RoboFTPClient.h" #include "RoboFTPClientDlg.h" #include "Eventsink.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern long gnResult...

how to avoid closing dialog if data validation fails
I would like to validate data entered in a dialog when the OK button is clicked. If there are problems with the data I would like to avoid closing the dialog and keep it open. Can anyone suggest how this is done? Thanks for any suggestions. Ian If you dont want to close your dialog in OnOk, do not call the base class OnOK. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "ian" <ib252@n0spam.com> wrote in message news:F1nnb.26812$He4.1099447@wagner.videotron.net... | I would like to validate data entered in a dialog when the OK button is | clicked. If there are problem...

Initialize Second Dialog
Hello: I have a dialog application that I've created, and I can initialize a combo box on this dialog box before it is shown. I also have a menu in this dialog. A selection from this menu opens another dialog box... CMyOtherDialog otherDiag; otherDiag.DoModal(); However, when I try to initialize a combo box in the otherDiag through the constructor, it doesn't work. I can add a button in otherDiag and once the user clicks it, it will populate the combo box, but the constructor doesn't do it. Any ideas? Saul775 "Saul775" <Saul775@discussions.microsof...

why cant i change font
i select all the text in a textbox and try to apply a font. nothing happens. that's the case with 4/5 fonts, only a few work. the same appears in both publisher 2003 and 2007. Are you creating a web page? Publisher will show 11 or so fonts when you are creating web pages. To use all the fonts, on the toolbar, Format, Font, uncheck Show only Web fonts. If above is not the issue, are you getting an error? -- Mary Sauer MVP http://msauer.mvps.org/ "ayudameconpublisher" <ayudameconpublisher@discussions.microsoft.com> wrote in message news:1BE1262A-A70B-4...

Default save of unsent messages to inbox NOT drafts: Why?
My Outlook automatically/by default saves unsent messages to the inbox not the drafts folder. Why? And how may I change this? Thank you. Vere Scott What version of Outlook? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer: anonymous@discussions.microsoft.com <anonymous@discussions.microsoft.com> asked: | My Outlook automatically/by default saves unsent messages | to the inbox not the drafts folder. Why? And how may I | change this? | | Thank you. | | Vere Scott ...

Change the Default Language Setting
Is it possible to set the language to 'English (Australia)' so it will be the default across all office applications? I keep having to change it manually in outlook at the moment. ...

Refresh modeless dialog
I have a piece of code: { create modeless dialog (with a rich text box in it). func(); } func() have a heavy job, it take a lot of time (3 - 5 minute). When func() is running, it update rich textbox with new text . But when i run my application, the dialog is created but, it has no chance to redraw. How to get modeless dialog updated (redraw) when func() is running ? Run func() in a thread. "Hai Ly Hoang" <NoReply@Mail.com> wrote in message news:ejKX7WDUEHA.3664@TK2MSFTNGP12.phx.gbl... > I have a piece of code: > { > create modeless dialog (with a rich text box in...

Alternative to common dialog / save as?
I'm using a skinning component which causes the default showSave dialog to appear misaligned and discolored (nothing I can do other than to stop working with the component). Is there a different way to show a standard "save as" dialog box? Maybe something without the search bar etc.? Thank you "John Smith" <spam@not-a-real-domain-name.com> wrote in message news:e2dGGWdCLHA.5412@TK2MSFTNGP04.phx.gbl... > I'm using a skinning component which causes the default showSave dialog to > appear misaligned and discolored (nothing I can do ot...

failed to send item dialog box when sending(why)
I keep getting failed to send item when I hit send on outlook ...

Font Color #2
When responding to an email, you have the option to mark your comments with your name or whatever. The comments font color always default to blue. Is there any way to change that default color without having to manually change it in the message? ...

Remove Page border for Particular Page
Hi, I am preparing a manual with MS Word 2003. I have set border for my entire document and I want to remove page border only for 4th page as I am inserting a flow chart. Could anyone guide me on this please? Regards, Mahesh -- maheshmaxi You will need to make that page a separate section (by means of Next Page section breaks before and after) and remove the page border for that section. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "maheshmaxi" <maheshmaxi.57e2213@wordbanter.com> w...

Synchronized zooming between pages
I have several pages in my drawing that I need to flip back and forth between. I'd like to zoom and pan between pages simultaneously so that all pages stay synchronized. This way, if I'm zoomed in on a portion of page 1, I can change to page 2 and I would be zoomed in on the same area. This can be for two pages using background/foreground pages to almost provide the same effect, but you can't 1) do it for more than 2 pages, 2) edit the background page at the same zoom level. Any help would be appreciated. I'm using Visio 2003, though could switch to 2007 if necessary...

Accessing a document from classes that are included in a dialog
Hi, I have a dialog that includes a class "ListBoxPair" which includes "ListBox". In this class, I would like to access the doc to update variables What is the best way to do it? Many thanks Thank you very much. I am sorry for the stupid question, I am just new in it: Should I write a constructor that gets this argument? How should it look like? An additional question, when it works, how do I go up to get this doc (from the class I mentioned before)? Thank you very much for your help "Scott McPhillips [MVP]" wrote: > Liat wrote: > > Hi, > &g...

Page Permission in MOSS2007
I have a problem with page permission in SP2007. I have posted all my pages under "Pages" and they are visible in the navigation for unauthorized/anonymous users. When I change permission of a page it is no longer visible in the navigation even if it has inherit the same permissions that all other pages. Any idéa? The site has anonymous users enabled and "Pages" area has all the user permissions, also "Site visitors" with user "DOMAIN\iusr_domainname". I have found answers regarding my question. When an item does not inherit permissions...

Changing margins on different pages in document templates.
I was wondering how you change the margins for different pages in a template. Specifically, my firm is using a letterhead for the first page but blank pages after that so the header and footer margins on the first page ONLY must be larger than normal, while the following pages are fine with default settings for the margins. How do you do this and save it as a template? See http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm, especially the "More complex letterhead" section. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://wo...

Messages not showing up in Properties window
I just converted a VC6 MFC app over to .NET and the Messages window is not showing anything when I click on a Dialog class in the class viewer. Some dialogs do show up, but I can't see anything that indicates why. MainFrm doesn't even show up. Has anyone seen this or know what causes it? Thanks, Steve I have seen that before. Click Solution view. Delete the ones that don't work and add them back into the project. Do that to both the .cpp and .h files Good Luck, Christopher J. Holland [!MVP] "SteveK" <asasd@asdfasdfsd.com> wrote in message news:el88qJiXEHA....

Moving the full text index property store
Hi, We are not using FT indexing, but the following directories exist in our clustered environment, i wish to move these from the existing disk to a new volume. X:\EXCHSRVR\ExchangeServer_%servername%\Config X:\EXCHSRVR\ExchangeServer_%servername%\GatherLogs X:\EXCHSRVR\ExchangeServer_%servername%\Projects I notice that you can use the pstoreutl.exe program to move store logs, does this move all three folders? http://technet.microsoft.com/en-us/library/08728b4b-6416-40c5-a5a9-8458d1012fbf.aspx Thanks Matthew Actually, there is a more specific article that talks about how to move the ...

"No more new fonts may be applied to this workbook"
I have an annoying problem that apparently has to do with the number of charts in my workbook. I am using Excel 2002 SP-1. I have a workbook that consists of 7 worksheets and is only 589 KB but I have a large number of charts. As I developed this workbook and the number of charts started to increase I started to get the error message, "No more new fonts may be applied to this workbook" even though I was not adding any new fonts. This usually happened when I tried to change the chart title. I would just click through several of these messages and everything would be OK. Now I cannot...

I have a graph paper on my page when I open microsoft word
I cannot find the 'draw' command on the non existant tool bar on microsoft word 2007 hence I cannot find the 'grid' to turn off to get these lines off my page. Help! View Tab>Show/Hide Group>Gridlines. maritime.chic wrote: > I cannot find the 'draw' command on the non existant tool bar on > microsoft word 2007 hence I cannot find the 'grid' to turn off to get > these lines off my page. Help! It's on the ribbon, but on a tab that's available only when a shape is selected. Go to the Insert tab and insert anything fro...

How can I reset defaults for cell borders? i.e color and/or inte.
I want to be able to modify border colors and intesity for cells in a worksheet. 1-choose the cellsformat/cells 2-choose format/cells 3-click on Border tab 4-choose the line style and color 5-click kind of vorder u want to have. 6-to reset defaults for cell borders, click "none" "mffoster" wrote: > I want to be able to modify border colors and intesity for cells in a > worksheet. ...

Excel default number format problem
I have a user with an incorrect default cell format in Excel. His default number of decimal places for a cell with numbers is set to 4 instead of 2. I have no idea how he caused this and I have no idea how to correct it. In case I'm being ambiguous, here is the procedure: Open a new Excel workbook, choose any cell and go to Format. In the Format Cell dialog box go to the Number tab and choose the Number category. The Decimal Places box will be set to 2 by default but in this user's Excel it is set to 4. How do I get it back to the default of 2? http://www.imagedump.com/index.cgi?pick...

Font Issue
When the form first opens all the labels look perfect, but as soon as I scroll through records using a command button suddenly a few of the labels start to take on a bold appearance. The issue occurs with a same labels very time. I can't figure out what’s happening to the labels. Any suggestions? Thanks -- Message posted via http://www.accessmonster.com User, Nope, never seen that, so let's see if it can be duplicated... -Access version? -Patches installed? -Continous form? -Font? -Code that you are using to scroll with? -- Gina Whipp "I feel I h...

Datasheet view font options are missing
Hi All, The font options for my Access (2002) datasheet view are missing. All the fonts show up for form design, just not the datasheet view. Worse yet, the font I'm stuck with in datasheet view doesn't display all western characters properly. I tried repairing the installation, but it didn't help. Can anyone tell me how I might begin to fix this? - max Max, this happened with the original relese of Access 2002 of you had many fonts installed. From memory, MS fixed it with one of the service packs. Install SP3 for Office XP from: http://support.microsoft.com/s...

Pages for Database's Indexes.
What is a way to get the number of pages for each database's tables and indexes, so I can see all the number of pages and size. Just trying to streamline and check for fragmentation in indexes, and I have to either individual go through each database and go to each table and find out page size or is there a way to get everything in one query. Thanks -- Message posted via http://www.sqlmonster.com On Aug 5, 1:15=A0am, "Hoardling1 via SQLMonster.com" <u43783@uwe> wrote: > What is a way to get the number of pages for each database's tables and > ...