1).h文件中加入:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
2).c文件中加入
ON_WM_CTLCOLOR()宏
定义函数
HBRUSH CPCServerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetBkColor(RGB(255, 255, 0));
hbr = CreateSolidBrush(RGB(255, 255, 0));
break;
}
return hbr;
}
3)其他控件如下:
CTLCOLOR_BTN Button control
CTL......
阅读全文