How to modify the StaticText font and the statictext font
I checked the information on the Internet, which is comprehensive, but one problem is that it is prone to text and box inconsistencies. (Take a closer look, there are white spaces between the blue letter and the background)
To eliminate this blank, simply add m_brush.CreateSolidBrush (RGB (240,240,240); In the constructor. Here, RGB is set to the same silver gray as the background.
Statements in the CPP file:
Copy codeThe Code is as follows:
HBRUSH Class Name: OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView: OnCtlColor (pDC, pWnd, nCtlColor); // It is useless, but it cannot be used without it. It's strange!
If (pWnd-> GetDlgCtrlID () = IDC_STATIC _ ×××)
{
PDC-> SetTextColor (RGB (0, 0, 255); // blue font
PDC-> SelectObject (& m_font); // you can specify a font.
}
Return m_brush;
}
Result: