改变文本框内文字颜色

来源:互联网 发布:铃声多多mac版 编辑:程序博客网 时间:2024/06/10 07:51

1.定义CEditm_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;

}

 

原创粉丝点击