1. Add events
Open the properties of the window class that you want to change the background color and add the WM_CTLCOLOR message
2. Add code
Add lines 6-13 to the newly created OnCtlColor function as shown below
HBRUSH 窗口类名::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = 基类名::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
switch (nCtlColor)
{
case CTLCOLOR_DLG:
HBRUSH aBrush;
aBrush = CreateSolidBrush(RGB(255, 255, 255));
hbr = aBrush;
break;
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}