MFC dialog box to modify the background color:
In Cxxxdlg::oninitdialog (), add the following:
Cdialogex::setbackgroundcolor (RGB (155,170,190));
The effect is as follows:
MFC dialog box to add a background image:
In Cxxxdlg::oninitdialog (), add the following:
Cdialogex::setbackgroundimage (IDB_BITMAP1);
The effect is as follows:
MFC controls are consistent with the background: static controls
Add the OnCtlColor () function to the dialog box:
Effect:
You can see that only text boxes with the static ID are consistent with the background. Button controls
Insert the code:
UINT id = pwnd->getdlgctrlid ();
if (id = = IDC_RADIO1 | | id = = IDC_CHECK1)
{
pdc->setbkmode (TRANSPARENT);
CRect RC;
Pwnd->getwindowrect (&RC);
ScreenToClient (&RC);
cdc* DC = GetDC ();
Pdc->bitblt (0,0,RC. Width (), RC. Height (), dc,rc.left,rc.top,srccopy); Draw the parent window background picture first to the button
ReleaseDC (DC);
HBR = (hbrush):: Getstockobject (Null_brush);
}
Effect:
To modify the control font color:
Add code:
if (nCtlColor = = ctlcolor_static)
{
Pdc->settextcolor ((+ 0));
}
Note: This experience is from an instance code on CSDN download, easy to understand and practical, O (∩_∩) O.