打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
文本及背景颜色 WM_CTLCOLOR
userphoto

2017.02.22

关注
 
 


CEdit m_edit1;
DWORD bkColour;
DWORD txtColour;

BOOL CCEDIT4Dlg::OnInitDialog()
{

m_edit1.SetWindowText("Hello World!");
SetDlgItemText(IDC_EDIT2,"I like C++!");
}



void CCEDIT4Dlg::OnBlueradio2() 
{
bkColour = RGB(0,0,255);
txtColour = RGB(0,0,0);
m_edit1.SetFocus();
}

void CCEDIT4Dlg::OnGreenradio3() 
{
bkColour = RGB(0,255,0);
txtColour = RGB(128,128,128);
m_edit1.SetFocus();
}

void CCEDIT4Dlg::OnYellowradio4() 
{
bkColour = RGB(255,255,0);
txtColour = RGB(128,0,128);
m_edit1.SetFocus();
}

void CCEDIT4Dlg::OnRedradio1() 
{
// TODO: Add your control notification handler code here
bkColour = RGB(255,0,0);
txtColour = RGB(255,255,255);
m_edit1.SetFocus();
//GetDlgItem(IDC_EDIT2) ->SetFocus();
}

HBRUSH CCEDIT4Dlg::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);
pDC -> SetBkColor(bkColour);
pDC -> SetTextColor(txtColour);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
MFC中为对话框设置背景色
vc++设置控件的背景色
对话框背景色、静态文本和编辑框字体色、背景色设置 - 编程天地 - 一叶方舟
CStatic设置文字、字体、颜色和OnCtlColor的使用
vc中控件字体的设置
VC MFC中修改STATIC的文本颜色
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服