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

Source: Internet
Author: User

1. Add the font and color variables in the dialog box class declaration

Public: cfont m_myfont; // font object colorref m_mycolor; // color object

2. initialize the font and color in the oninitdialog () function of the dialog box initialization function.

// Todo: add additional initialization code m_myfont.createpointfont (150, _ T (" 文 "); m_mycolor = RGB (255, 0,255 );

3. Add the message response function wm_ctlcolor for the dialog box class, and add the code in its message response function onctlcolor ().

Afx_msg hbrush onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor); // message response function declaration
On_wm_ctlcolor () // message ing
Hbrush cxxxdlg: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor) // message response function implementation {hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor ); // todo: change any DC attributes here if (pwnd-> getdlgctrlid () = idc_static_week) {PDC-> SelectObject (& m_myfont ); // set the font PDC-> settextcolor (m_mycolor); // set the color} // todo: return another paint brush return HBr if it is not the required paint brush by default ;}

 

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.