『菜鸟送分』MFC中如何改变一个checkbox的字体颜色?? 不想重写类的代码,有没有函数直接设置颜色,报括CButton上的字体颜色??我用settextcolor好像不行,诸位看看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果你只是一开始改变一次可以重载过OnCtlColor()HBRUSH CMyDlg::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_CHECKBOX)// radio的ID { pDC->SetTextColor(RGB(0,0,255)); } // TODO: Return a different brush if the default is not desired return hbr;}或者派生你的Edit 类 if (GetStyle() & ES_READONLY) { pDC->SetBkMode(TRANSPARENT); return static_cast<HBRUSH>(m_pDisableBrush->GetSafeHandle()); } else { pDC->SetBkMode(OPAQUE); return static_cast<HBRUSH>(m_pNormalBrush->GetSafeHandle()); return NULL; } MFC程序关闭,管理器中进程依然运行的问题 MessageBox接收串口数据的问题 关于activex web控件的重绘问题 关于QQ08、09、10版本密码框的问题 MFC中不同对话框的数据传递 菜鸟请教关于硬盘写入的问题! 送分题 菜鸟问题 ----------我中招了,请大家帮忙!-------- 如何弹出一个窗口? [公开道歉]破坏版内团结,向广大网友和zhucde大版道歉 各位高手
HBRUSH CMyDlg::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_CHECKBOX)// radio的ID
{
pDC->SetTextColor(RGB(0,0,255));
} // TODO: Return a different brush if the default is not desired
return hbr;
}或者
派生你的Edit 类
if (GetStyle() & ES_READONLY)
{
pDC->SetBkMode(TRANSPARENT);
return static_cast<HBRUSH>(m_pDisableBrush->GetSafeHandle());
}
else
{
pDC->SetBkMode(OPAQUE);
return static_cast<HBRUSH>(m_pNormalBrush->GetSafeHandle());
return NULL;
}