在对话框中我重载了OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor),能改变对话框背景色,文字颜色,但按钮的颜色改不掉,函数如下:
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = MyColor;
// TODO: Change any attributes of the DC here
switch(nCtlColor) {
case CTLCOLOR_EDIT:
case CTLCOLOR_STATIC:
pDC->SetBkColor(RGB(122,177,184));
break;
case CTLCOLOR_BTN:
pDC->SetBkColor(RGB(255,0,245));
break;
case CTLCOLOR_MSGBOX:
pDC->SetBkColor(RGB(255,0,245));
break;
default:
break;
}
pDC->SetTextColor(RGB(0,255,249));
// TODO: Return a different brush if the default is not desired
return hbr;
}MyColor设定了背景颜色。我跟踪调试过,确定
case CTLCOLOR_BTN:
pDC->SetBkColor(RGB(255,0,245));
break;执行到了。
请高手们指导!
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = MyColor;
// TODO: Change any attributes of the DC here
switch(nCtlColor) {
case CTLCOLOR_EDIT:
case CTLCOLOR_STATIC:
pDC->SetBkColor(RGB(122,177,184));
break;
case CTLCOLOR_BTN:
pDC->SetBkColor(RGB(255,0,245));
break;
case CTLCOLOR_MSGBOX:
pDC->SetBkColor(RGB(255,0,245));
break;
default:
break;
}
pDC->SetTextColor(RGB(0,255,249));
// TODO: Return a different brush if the default is not desired
return hbr;
}MyColor设定了背景颜色。我跟踪调试过,确定
case CTLCOLOR_BTN:
pDC->SetBkColor(RGB(255,0,245));
break;执行到了。
请高手们指导!
解决方案 »
- 用CreateBitmap生成的CBitmap在CImageList显示全黑的问题
- CreateMutex为什么失败?
- 如何从bits数据得到HBITMAP?
- [求助]请问我这段代码里的一个线程是怎么执行的
- 使用vc6自带的串口通讯控件,持续的调用控件的接收数据的函数来读接收缓冲区,会发现,程序占用内存不断的有规律的增大,这是为什么?
- 蹭分的别进!如何在一个类中访问另一个类的protect成员函数,解决后立即给分
- 常规dll基础问题
- CPen(PS_SOLID,16,RGB(255,0,0));画出来的线不是红的,Y?
- 在atl工程中如何向excel插入控件??
- richedit内容导出到html
- 我迷惑!请高手指点!
- 请高手指点,钩子钩子!!!!!!!
http://www.codeguru.com/Cpp/controls/buttonctrl/article.php/c2087
你可以下一个CButtonST直接来用,很简单,
而且有源码,也可以参考自己写
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_BTN:
if(pWnd->GetDlgCtrlID() == IDC_BUTTON)
{
return m_hbrush;
} }
// TODO: Return a different brush if the default is not desired
return hbr;
}
在.h文件中定义好HBRUSH m_hbrush;
最后再在你的BUTTON代码断加上m_hbrush=CreateSolidBrush(RGB(0,0,255));
就可以了。
vchelp.net也不错..
再不行 去那个外国的 好象是 codeproject.com吧..旧知道这些了:__(