Re: Font in Dialog
- From: "Dan McCarty" <dmccarty@xxxxxxxxx>
- Date: 29 Apr 2005 13:04:11 -0700
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.
.
- References:
- Font in Dialog
- From: M.Eger
- Font in Dialog
- Prev by Date: Re: _ecvt, _gcvt and _fcvt problem
- Next by Date: Re: How to determine current service pack?
- Previous by thread: Font in Dialog
- Next by thread: Application doesn't work in Release mode on Pocket PC 2003
- Index(es):
Relevant Pages
|