IDC_ShowTime is the ID of the edit box.
M_showtime is the variable in the static edit box.
1. In dlg. h
CBrush m_showtimeBrush;
CFont m_editFont; // font
2. OnInitDialog ()
M_showtimeBrush.CreateSolidBrush (RGB (204,0, 204); // edit the background color of the box.
CEdit * m_EditAa = (CEdit *) GetDlgItem (IDC_ShowTime); // IDC_ShowTime is the edit box ID.
M_editFont.CreatePointFont (220, _ T (""); // select the font
M_EditAa-> SetFont (& m_editFont );
3. Add OnCtlColor in the class Wizard
HBRUSH CmyDlg: OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx: OnCtlColor (pDC, pWnd, nCtlColor );
If (m_showtime.m_hWnd = pWnd-> m_hWnd) // m_showtime is the variable in the static editing box.
{// PDC-> SetBkColor (RGB (0,255, 0); // font background
PDC-> SetBkMode (TRANSPARENT); // the editing box is TRANSPARENT.
PDC-> SetTextColor (RGB (255,255,255); // text color
PDC-> SelectObject (& m_editFont );
Return m_showtimeBrush;
} // TODO: if the default paint brush is not required, another paint brush is returned.
Return hbr;
}
Result: (the dialog box is also set, and the purple part is the static edit box effect)
Change the static text background color, font setting, and font background of the static editing box.