Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I change the backround color for dialog boxes?

Status
Not open for further replies.

Pyropat

Programmer
May 21, 2001
9
US
See the subject line...
thanx
 
class CTestDlg : public CDialog
{
...
protected:
CBrush m_brush;
...
};

BOOL CTestDlg::OnInitDialog()
{
...
m_brush.CreateSolidBrush(RGB(255, 255, 255)); // color white brush
...
}

HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
/*
** No need to do this!
**
** HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
*/

/*
** Return the white brush.
*/
return m_brush;
}

I found it in an article at hope that helps. Check more out here
-CDudd
 
The above code will not the desired result.
You need to :
a - Return the brush in CTestDlg::OnCtlColor and not in
CAboutDlg::OnCtlColor.
b - check the nCtlColor parameter, that indicates which
control asks for the brush to paint itself. You should
check for the value that indiactes the Dialog window itself, not one of the child conrols in it (I forgot the value name, you can check it in the Help item of OnCtlColor.

Good Luck ======
SeekerOfKnowledge
======
 
For an MFC Dialog, you have 2 .cpp files (Thing.cpp and ThingDlg.cpp). The following line goes in ThingApp::InitInstance() in Thing.cpp:

SetDialogBkColor(RGB(0,0,0), RGB(255,255,255));

The first arg is the background, the second is the foreground. Hope this helps!

--Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top