Re: Fonts
Ed I think you have missed a couple of points from the last thread.
1. You need to make LabelFont part of your class deceleration, or else it
will go out of scope.
2. Assuming c_Text1 is a variable attached to IDC_INFO then you simply have
to call SetWindowText on it.
c_Text1.SetWindowText("Something");
3. You don't need to call UpdateWindow(); as SetWindowText will update the
display automatically.
Here is kinda what it should look like.
class CMyDialog : public CDialog
{
public:
......
private:
CFont LabelFont;
CStatic c_Text1;
};
void CMyDialog::DoDataExchange(....)
{
CDialog::DoDataExchange();
DDX_Control(pDX,IDC_INFO,c_Text1);
}
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CFont * f = c_Text1.GetFont();
ASSERT(f != NULL);
LOGFONT lf;
f->GetLogFont(&lf);
lf.lfHeight *= 5;
lf.lfWeight = FW_BOLD;
LabelFont.CreateFontIndirect(&lf);
c_Text1.SetFont(&LabelFont);
c_Text1.SetWindowText("Text");
return TRUE;
}
AliR.
"Ed" <ed@ed.com> wrote in message
news:jdCdnRGrcrBQijnUnZ2dnUVZ_vKdnZ2d@giganews.com...
Font size
Here is what I did? Have I done anything wrong?
In OnInitDialog() I have added:
CFont LabelFont;
CFont * f = c_Text1.GetFont();
ASSERT(f != NULL);
LOGFONT lf;
f->GetLogFont(&lf);
lf.lfHeight *= 5;
lf.lfWeight = FW_BOLD;
LabelFont.CreateFontIndirect(&lf);
c_Text1.SetFont(&LabelFont);
========================================================
I used to display the message like the following:
void CMyDlg::OnSelect1()
{
GetDlgItem(IDC_INFO)->SetWindowText("MY MESSAGE"); //new message
UpdateWindow(); //display it
}
Now, how do I get the string to display with the new font
without using GetDlgItem?
Thanks