I am using static text controls as labels. I want to make a few of these labels bold on my form. How do I do this
Regards Diana
Printable View
I am using static text controls as labels. I want to make a few of these labels bold on my form. How do I do this
Regards Diana
check "other controls" or "static" sections on this site.
there is sample there that show derived from CStatic labels which use any font, any color, custom background ....
I just don't remember article name.
here it is
// CTestDlg.h
class CTestDlg : public CDialog
{
...
protected:
CFont m_BoldFont;
...
};
// CTestDlg.cpp
...
BOOL CTestDlg::OnInitDialog()
{
...
// Create bold font
CFont* pFont=GetFont();
LOGFONT lf;
pFont->GetLogFont(&lf);
lf->lfWeight=FW_BOLD;
m_BoldFont.CreateFontIndirect(&lf);
...
}
HBRUSH CTestDlg::OnCtlColor(CDC* pDC,CWnd* pWnd,UINT nCtlColor)
{
HBRUSH hbr=CDialog::OnCtlCOlor(pDC,pWnd,nCtlColor);
switch (pWnd->GetDlgCtrlID())
{
// add ID's of labels that should be displayed as bold
case IDC_LABEL1:
case IDC_LABEL2:
pDC->SelectObject(&m_BoldFont); // Set bold font as default font in device context
break;
}
return hbr;
}