1、添加以下宏,处理WM_CTLCOLOR*消息
MESSAGE_HANDLER(WM_CTLCOLOR*, OnCtlColor)
2、在OnCtlColor中:
LRESULT CAboutDlg::OnCtlColor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CWindow wndText1 = GetDlgItem(IDC_TEXT1);
HDC hdc = (HDC)wParam;
if ( (HWND)lParam == wndText1 .m_hWnd )
{
::SetTextColor(hdc, RGB(255, 0, 0));
::SetBkColor(hdc, ::GetSysColor(CTLCOLOR_DLG));
// 返回一个画刷告知该消息已处理,不用执行默认动作了
return (LRESULT)::GetSysColorBrush(CTLCOLOR_DLG);
}
return 0;
}