how to change the backcolor of a dialog?
VIP
Printable View
how to change the backcolor of a dialog?
VIP
Try using SetWindowLong to set the background handle. Not sure if it will work, it just comes to my mind.
Else you might want to catch the WM_ERASEBKGRND message
how to find the background handle?
SetClassLong(hDlg, GCL_HBRBACKGROUND, hNewBrush);
You must first create the new brush somehow.
If I use a brush it gives the error:
'Cannot convert parrameter 3 from CBrush to long'
so I used RGB(0,0,0) but then the color of the dialog doesn't change. I places the code in the Paint function.
what's wrong?
Use
br.GetSafeHandle();
And don't place the code in OnPaint but rather in OnCreate.
I still can't guarantee it will work.
it doesn't work :(
Search for CWnd::OnEraseBkgnd in the reference. This is what you need then.
isn't in the list :(
the dialog created with MFC is a CWnd Class? isn't it?
VIP
CDialog is derived from CWnd
Search for WM_ERASEBKGND and then choose CWnd::OnEraseBkgnd from the popup window.
Basically this function is called so you can erase the background of your window. Simply draw in whatever color you want to.
I'm sorry, but it really isn't in the list, it goes from WM_DRAWITEM to WM_HELPINFO.
Download the newest SDK, you're misssing not only WM_ERASEBKGND but also
WM_DROPFILES, WM_ENDSESSION, WM_ENTERIDLE and many others...
which one? there are more than one.