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)