CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 1999
    Location
    Sydney, Australia
    Posts
    33

    Making a Static text control Bold

    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


  2. #2
    Join Date
    Jul 1999
    Posts
    10

    Re: Making a Static text control Bold

    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.





  3. #3
    Join Date
    Jul 1999
    Posts
    10

    http://www.codeguru.com/staticctrl/label_static.shtml

    here it is


  4. #4
    Guest

    Re: Making a Static text control Bold

    // 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;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured