After checking the information on the Internet, some are relatively comprehensive, but one problem is that it is easy for the text and the frame to not match. (Look carefully, there are gaps between the blue letters and the gray background)
To eliminate this gap, it is very simple to add m_brush.CreateSolidBrush(RGB(240,240,240)); in the constructor. The RGB is set to the same silver gray as the background.
Statements in the CPP file:
Copy the code code as follows:
HBRUSH class name::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor); //Obviously useless, but it doesn't work without it, very strange!
if (pWnd->GetDlgCtrlID()==IDC_STATIC_×××)
{
pDC->SetTextColor(RGB(0,0,255)); //Blue font
pDC->SelectObject(&m_font); //Set the set font
}
return m_brush;
}