Quote:
>Does any one know how to change the font size of a control
>box? My control is created from the resource view. I
>looked into the property of the window. But to do it from
>there, once the font size is changed, the whole box is
>enlarged, and every control on the dialog box will be
>changed. I would like to change the font size of a single
>control box without changing the box size. Please help
You'll have to send it a WM_SETFONT message, and the easiest way is to bind
a control to it with ClassWizard and call SetFont on it. Make sure the font
outlives the control. One way is to add a CFont member variable to your
dialog class and use that font. To change just the font size, you first need
to obtain the control's current font. Here's how I added underlining to a
control's font, which is a similar problem:
// This code was actually in the control's PreSubclassWindow override.
CFont* pFont = GetFont();
if (!pFont)
{
pFont = GetParent()->GetFont();
if (!pFont)
{
if (HFONT hFont =
static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)))
pFont = CFont::FromHandle(hFont);
}
}
if (pFont)
{
LOGFONT lf;
pFont->GetLogFont(&lf);
lf.lfUnderline = true;
if (m_font.CreateFontIndirect(&lf))
SetFont(&m_font);
}
--
Doug Harrison
Microsoft MVP - Visual C++