How to fix the font of StaticText

  • 2020-04-01 01:37:03
  • OfStack

Checked the data on the net, have more comprehensive, but there is a problem is easy to appear a text and frame does not conform to the phenomenon. (look carefully, there is white space between the blue letters and the gray background.)

< img border = 0 SRC = "/ / files.jb51.net/file_images/article/201303/2013313105814600.png" >

To remove this blank, simply add m_brush.createsolidbrush (RGB(240,240,240)); That's in the constructor. Where RGB is set to the same silver gray as the background.

Statements in the CPP file:


HBRUSH  The name of the class ::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
 HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);   //It doesn't work, but it doesn't work without it. It's weird!
 if (pWnd->GetDlgCtrlID()==IDC_STATIC_ XXX )  
 {
    pDC->SetTextColor(RGB(0,0,255));  //Blue font
    pDC->SelectObject(&m_font);    //Sets the set font
 }
 return m_brush;  
}

Results:

< img border = 0 SRC = "/ / files.jb51.net/file_images/article/201303/2013313110045468.png" >


Related articles: