Set the font and color of the static text box in the dialog box

Source: Internet
Author: User

1. Add the font and color variable [cpp] public: CFont m_myFont; // font object COLORREF m_myColor; // color object 2. initialize the OnInitDialog () function in the dialog box () initialize the font and color [cpp] // TODO: add additional initialization code m_myFont.CreatePointFont (150, _ T (" 文 "); m_myColor = RGB (255, 0,255); 3. Add the WM_CTLCOLOR message response function for the dialog box class, and add the Code [cpp] afx_msg HBRUSH OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor); // message response function declaration [cpp] ON_WM_CTLCOLOR () // message ing [cpp] HBRUSH CXXXDlg: OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor) // message response function implementation {HBRUSH hbr = CDialog: OnCtlColor (pDC, pWnd, nCtlColor); // TODO: change any DC property here if (pWnd-> GetDlgCtrlID () = IDC_STATIC_WEEK) {pDC-> SelectObject (& m_myFont); // set the font pDC-> SetTextColor (m_myColor ); // set the color} // TODO: if the default paint brush is not required, return another paint brush return hbr ;}

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.