MFC background and text color

Source: Internet
Author: User

Define a member variable cbrush m_brush;
Initialize m_brush.createsolidbrush (RGB (255, 0) in oninitdialog ));
In onctrlcolor
Hbrush casdfaaaaaaaaadlg: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
Hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor );
If (nctlcolor = ctlcolor_edit &&
Pwnd-> getdlgctrlid () = idc_edit1) // note (pwnd->) Here, otherwise it will not work.
{
PDC-> settextcolor (RGB (255, 0, 0 ));
PDC-> setbkcolor (RGB (255,255, 0); // sets the text background color.
PDC-> setbkmode (transparent); // sets the background transparency.
HBr = (hbrush) m_brush;
}
Return HBr;
}
The nctlcolor type is as follows:
Ctlcolor_btn button control
Ctlcolor_dlg dialog box
Ctlcolor_edit Edit Control
Ctlcolor_listbox list-box Control
Ctlcolor_msgbox message box
Ctlcolor_scrollbar scroll-bar Control
Ctlcolor_static Static Control

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.