Changing the background color of a dialog
Posted
by Luis Garcia
on February 8th, 1999
In your CTestDlg header file, declare a member variable from CBrush:
class CTestDlg : public CDialog
{
...
protected:
CBrush m_brush;
...
};
Then, add this line in the OnInitDialog function:
BOOL CTestDlg::OnInitDialog()
{
...
m_brush.CreateSolidBrush(RGB(255, 255, 255)); // color white brush
...
}
Finally do this on the ID_CTLCOLOR handle:
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;
}
Hope this could help any fellow programmer!
Date Last Updated: February 8, 1999

Comments
What about ::AfxMessageBox or CWnd::MessageBox
Posted by Legacy on 02/24/2004 12:00amOriginally posted by: Its not a toomah!
I want to also change the background of ::AfxMessageBox or CWnd::MessageBox.
Can anybody here tell me how to do this?
Thx
ReplyBackground color of dialog
Posted by Legacy on 11/26/2003 12:00amOriginally posted by: Aqualung
It's much easier to do the following in the InitInstance:
SetDialogBkColor(RGB(255,255,255),RGB(0,0,0));
-
ReplySetDialogBkColor problem??
Posted by break; on 07/01/2009 08:43amHi, SetDialogBkColor dont work in my project, and i dont know why?? :( Any idea for this? regards break;
Replythanks a lot,and a piece of advice
Posted by Legacy on 10/22/2003 12:00amOriginally posted by: Alex
I am wondering about control background color changing. Through effect I find those methods mentioned in this article can change only color of text and dialog background.If we want to change the color of control,we must override the control class indivisually and rewrite their functions like DrawItem ,etc.
Welcome comments about this opinion.
Reply
Alternate simple ways to change the dialog background color
Posted by Legacy on 09/22/2003 12:00amOriginally posted by: Jes
ReplyHow to Change MessageBox Background?
Posted by Legacy on 02/07/2003 12:00amOriginally posted by: Anand Shah
Hi the code mentioned does not work for Message Box's.
Can anyone help with changing the Background color of the MessageBox.
-
ReplyHow to Change MessageBox Background?
Posted by Mark Veldt on 05/14/2004 08:07pmSearch for Q99808 in Google. Microsoft has an example
ReplyI have a concern
Posted by Legacy on 12/05/2002 12:00amOriginally posted by: Deandrea Venon
I need information on creating an atm application.
The user should be able to enter deposit and withdrawal.
In the end closing balance would be shown
as:
closingbalance=openingbalance+deposit-withdrawal
i have attempted it but it displays anassertion error. then everything in the dialog becomes blank. Please help!!
ReplyOK How to do it on a multi form app??
Posted by Legacy on 05/30/2002 12:00amOriginally posted by: javajunkie
I have an app I would like to have the option of colors on each of 7 or 8 different forms that are CRecordViews. I can get the first form color changed but not the rest of them. I am using the OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) method. Any ideas on how to make all the forms have the background color changed?
I know this isn't much deatil but if someone thinks they have a way I can provide the details for them.
TIA
ReplyHow can I change check box's color and radio button color
Posted by Legacy on 05/01/2002 12:00amOriginally posted by: cthSon
Button, radio and checkbox do not chang color
ReplyCan't change bgcolor of messageboxes.
Posted by Legacy on 04/09/2002 12:00amOriginally posted by: Pkun
It does not work for messageboxes. How can I change messagebox's background?
Replythank you
Posted by Legacy on 03/08/2002 12:00amOriginally posted by: linxiao
ReplyLoading, Please Wait ...