关于网友提出的“ 如何改变Edit控件的背景颜色和字的颜色?”问题疑问,本网通过在网上对“ 如何改变Edit控件的背景颜色和字的颜色?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 如何改变Edit控件的背景颜色和字的颜色?
描述: 如题。
解决方案1: 重载OnCtlColor();
HBRUSH CMydilog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
int nID = pWnd->GetDlgCtrlID();
pDC->SetBkMode(OPAQUE);
if( nID == IDC_EDIT2)
{
pDC->SetTextColor( RGB( 0,128,0 ) );//文字
pDC->SetBkColor(RGB(200,255,200));背景
}
return hbr;
}
楼主搜索一下以前的帖子就可以看到很多答案
以上介绍了“ 如何改变Edit控件的背景颜色和字的颜色?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2752653.html