如何更改组框的背景颜色? [英] how to change the group box's background color?

查看:134
本文介绍了如何更改组框的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们

如何在MFC对话框中更改组框的背景色?

我的对话框中有几个分组框,我想将其中一些更改为不同的颜色,该怎么做?

感谢

解决方案

帕利尼

我使用了这种方法,但没有任何反应

HBRUSH CTempDetDlg :: OnCtlColor(CDC * pDC,CWnd * pWnd,UINT nCtlColor)
{

HBRUSH hbr = CDialog :: OnCtlColor(pDC,pWnd,nCtlColor);
//TODO:在此处更改DC的任何属性
if(pWnd-> GetDlgCtrlID()== IDC_STA1)//组框的ID
{

pDC-> SetBkColor(BLACK);//
pDC-> SetBkMode(TRANSPARENT);
hbr =(HBRUSH)m_brush;
}

return hbr;
}
CBrush m_brush;
m_brush.CreateSolidBrush(BLACK);

没用

顺便说一句,我已经在
中设置了对话框的背景色 BOOL CTempDetApp :: InitInstance()

SetDialogBkColor(RGB(0xF0,0xFF,0xFF),RGB(0x00,0x00,0x00));

它起作用了,现在我要设置组框的背景颜色


覆盖对话框的OnCtlColor方法,例如,参见 解决方案

hi ,Pallini

I used that method but nothing happens

HBRUSH CTempDetDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{

HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID()==IDC_STA1) //group box''s id
{

pDC->SetBkColor(BLACK);//
pDC->SetBkMode(TRANSPARENT);
hbr = (HBRUSH)m_brush;
}

return hbr;
}
CBrush m_brush;
m_brush.CreateSolidBrush(BLACK);

it didn''t work

BTW, i already set the background color of dialog in
BOOL CTempDetApp::InitInstance()

SetDialogBkColor(RGB(0xF0,0xFF,0xFF),RGB(0x00,0x00,0x00));

it works, now i want to set group box''s background color


Override the OnCtlColor method of your dialog box, see, for instance, an example here [^].


这篇关于如何更改组框的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆