测试代码基于对话框,m_edit 就是 你的edit,处理对话框的消息 WM_CTLCOLOR
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd == &m_edit)
{
pDC->SetTextColor(RGB(0,0,255));
}
return hbr;
}
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd == &m_edit)
{
pDC->SetTextColor(RGB(0,0,255));
}
return hbr;
}
![](https://i-blog.csdnimg.cn/blog_migrate/d86522e41a1c53b89e1ee8cb29d370e3.gif)
本文标签: