Click here to Skip to main content
14,937,212 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, guys

how to change the background color of group box in dialog of MFC?

there are several group boxes in my dialog, i want to change some of them to different color, how to do this?


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

hbr = (HBRUSH)m_brush;

return hbr;
CBrush m_brush;

it didn't work

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


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 [^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900