Change the static text background color, font setting, and font background of the static editing box.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.