Re: Font in Dialog

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



M.Eger wrote:
> i have a dialog based app and i want to set the font for all
dialogboxes
> global. Like i could do this in the ressource-editor for all dialog
boxes.
> Can i do this with code? For example in the OnInitDialog function.

We do something like this. We have a parent dialog class that creates
a few fonts. Each child dialog can use its parent's fonts and in the
OnInitDialog function we set various controls to different fonts.

If you wanted all controls to use the same font you could do something
like this (off the top of my head):
int controlIDs[DIALOG_X_NUM_CTLS] =
{ IDC_BN_OK,
IDC_BN_CANCEL,
[...]
}

for (int i = 0; i < sizeof(controlIDs) / sizeof(controlIDs[0]); i++)
{
pWnd = GetDlgItem(controlIDs[i]);
ASSERT(pWnd);
pWnd->SetFont(&m_parentFont);
}

For some dialogs where I have a lot of dynamically-created controls I
use resource IDs that are sequentially numbered--e.g., IDC_ED_0 (=
1950) - IDC_ED_23 (= 1973). Then I can just loop like

for (i = IDC_ED_0; i < IDC_ED_23; i++)

and not worry about having to manage the above control array. (I guess
I do have to manage resource.h instead, so maybe both ways of doing it
are about the same.)

Hope this helps,
Dan.

.



Relevant Pages

  • Re: solving for various font sizes
    ... More and more users are using larger fonts and this is causing lots ... I would like to have a real fix for this problem--and am willing to ... The TGridPanel and TFlowPanel controls can help for this. ... So if you have a checkbox on your form you might do this in the ...
    (borland.public.delphi.non-technical)
  • Re: Userform : Font size problem
    ... the site you are referring to talks about dealing with *cells* fonts within VBA. ... Using XL2003 VBA, I'm designing a user form, and I have a hard time getting the font size I wish when changing controls properties. ...
    (microsoft.public.excel.programming)
  • Re: solving for various font sizes
    ... More and more users are using larger fonts and this is causing lots ... I would like to have a real fix for this problem--and am willing to ... The TGridPanel and TFlowPanel controls can help for this. ... So if you have a checkbox on your form you might do this in the ...
    (borland.public.delphi.non-technical)
  • Re: VB6 Q: setting tab order at runtime
    ... >suddenly turns into 800 and some controls drop out of sight. ... >Small fonts give you 15 twips per pixel, while Large fonts give you 12 twips ...
    (microsoft.public.vb.controls)
  • Re: Formatting in Runtime
    ... You could use the Open event of the report to loop through its Controls ... Enumerating System Fonts ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.reports)