1.定义 CEdit m_edit 成员变量;
2.
COLORREF colour;
colour = RGB(255,0,0);
m_edit.SetFocus();
3.增加消息响应函数 HBRUSH CColourTextDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
内容为:
HBRUSH CColourTextDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor == CTLCOLOR_EDIT)
pDC->SetTextColor(colour);
// TODO: Return a different brush if the default is not desired
return hbr;
}