MFC changes the control color completely (dialog box)

Source: Internet
Author: User

Hbrush Cxxxdlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor)
{
Hbrush HBR = Cdialog::onctlcolor (PDC, PWnd, nCtlColor);
TODO: Change any of the properties of the DC here
if (NCTLCOLOR==CTLCOLOR_BTN)//Change button color
{
Pdc->setbkmode (TRANSPARENT);
Pdc->settextcolor (RGB (0,0,0));
Pdc->setbkcolor (RGB (121,121,255));
Hbrush B=createsolidbrush (RGB (121,121,255));
return b;
}
else if (Nctlcolor==ctlcolor_scrollbar)//
{
Pdc->setbkmode (TRANSPARENT);
Pdc->settextcolor (RGB (0,0,0));
Pdc->setbkcolor (RGB (233,233,220));
Hbrush B=createsolidbrush (RGB (233,233,220));
return b;
}
else if (nctlcolor==ctlcolor_edit)//change edit box
{
Pdc->setbkmode (TRANSPARENT);
Pdc->settextcolor (RGB (0,0,0));
Pdc->setbkcolor (RGB (165,254,236));
Hbrush B=createsolidbrush (RGB (165,254,236));
return b;
}
else if (nctlcolor==ctlcolor_static)//change static text
{
Pdc->settextcolor (RGB (0,0,0));
Pdc->setbkcolor (RGB (204, 204, 153));
Hbrush B=createsolidbrush (RGB (204, 204, 153));
return b;
}
else if (NCTLCOLOR==CTLCOLOR_DLG)//Change dialog box background color
{
Pdc->settextcolor (RGB (0,0,0));
Pdc->setbkcolor (RGB (204, 204, 153));
Hbrush B=createsolidbrush (RGB (204, 204, 153));//
return b;
}
TODO: If the default is not the desired brush, another brush is returned
return HBR;
}

Dlg dialog box to add a message to inherit the OnCtlColor function:

Hbrush Cfunctioncalldlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor)
{
Hbrush HBR = Cdialogex::onctlcolor (PDC, PWnd, nCtlColor);

TODO: Change any of the properties of the DC here

if (nCtlColor = = Ctlcolor_dlg | | nctlcolor = = ctlcolor_static) {//You can make the static text box (Edit,checkbox,groupbox) equal to the background color

Pdc->settextcolor (RGB (0, 0, 0));
Pdc->setbkcolor (RGB (204, 204, 153));
Hbrush B = CreateSolidBrush (RGB (204, 204, 153));
return b;
}

The following is a change to the background color of the word, and some gaps are not filled

if (pwnd->getdlgctrlid () = = Idc_statictestcasename | | pwnd->getdlgctrlid () = = Idc_check_designmodel | | pWnd- >getdlgctrlid () = = Idd_functioncall_dialog)
//{
Pdc->settextcolor (RGB (0, 0, 0)); Font Color
Pdc->setbkcolor (RGB (204, 204, 153)); Font background color
//}

MFC changes the control color completely (dialog 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.