建议楼主处理OnCtlColor消息~~~
在VC技术内幕里面有提到了该问题~~~
Setting the Color for the Dialog Background and for Controls
说明如下:
The parent dialog is sent a WM_CTLCOLOR message for each control immediately before the control is displayed. A WM_CTLCOLOR message is also sent on behalf of the dialog itself. If you map this message in your derived dialog class, you can set the foreground and background text colors and select a brush for the control or dialog nontext area.
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)//假如是EDIT控件
{
pDC->SetBkColor(RGB(255, 255, 0)); // yellow
return m_hYellowBrush;
}
if (nCtlColor == CTLCOLOR_DLG) //是DLG控件
{
pDC->SetBkColor(RGB(255, 0, 0)); // red
return m_hRedBrush;
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
这样就可以达到效果 ~~~
Contains one of the following values, specifying the type of control:
• CTLCOLOR_BTN Button control
• CTLCOLOR_DLG Dialog box
• CTLCOLOR_EDIT Edit control
• CTLCOLOR_LISTBOX List-box control
• CTLCOLOR_MSGBOX Message box
• CTLCOLOR_SCROLLBAR Scroll-bar control
• CTLCOLOR_STATIC Static control
上面为常见控件的标示值.
这个是MSDN里面的介绍~~