HBRBACKGROUND class member Question

I would like my dialog box to display using a different background color for the buttons, static displays, dialog background (pretty much everything). In my WM_INITDIALOG, I'm calling SetClassLong with parms:

hwnd (dialog box hwnd),
GCL_HBRBACKGROUND,
HBRUSH (brush handle from successful CreateSolidBrush)

However, I receive error back. Why won't this work.

Alternatively, I can use WM_CTLCOLORBTN/DLG/EDIT/... and return my brush handle there. However, doing so works for DLG but BTN ignores me. Also, even if I got BTN to take my brush the borders around DLG and BTN are still colored according to system 3-D objects color. Therefore, I would like to get the first method to work instead.

Thanks for help!
elmo2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RONSLOWCommented:
Your first method would not be the preferrd way to go.  I don't think it works anyway if you you have 3D style dialogs.  Also it would only change background of the dialog not anything else (like frames and button etc).

The best and most flexible solution is WM_CTLCOLORxxx

However, as you said, this does NOT work for buttons (as you said).  You need to make owner drawn buttons and paint them yourself.  From the sounds of things, you want pretty much complete control over the appearance of your dialog, so that is probably the best way to go anyway.
 
0
elmo2Author Commented:
Hmm, but the border problem applies to everything in addition to buttons, including text frames, list box borders, dialog itself borders etc. etc. I can't ownerdraw everything and I'm sure there's gotta be a simple solution since SDK says that all controls derive their bg color from HBRBACKGROUND class style. If I change appearance color for 3-d objects in control panel, everything works how I would like (except for ALL programs using my color). I apreciate your time/help but I gotta hope for and hold out for a better solution (if there is one).

0
RONSLOWCommented:
But borders do NOT derive their color from the HBRBACKGROUND brush - they come from the system colors for 3dhighlight , 3d shadow etc (ie. the ones in the control panel)  Changing the background brush will NOT do it.  The only way is to owner draw them.  This is because your app is using CTL3D32.DLL to do the drawing of controls (see your winapp for wher eit turns on 3D controls).

If you _weren't_ doing 3d controls, you'd be better off calling SetDialogBkColor instead - which also changes button faces. Or you could then change individual button faces with the OnCtlColor (which will work if you don't have 3D controls on).  But if you turn off 3D controls, they will not appear 3D - so if you want nice borders, you're back to owner drawn again.

I'm sorry - but changing HBRBACKGROUND won't do what you want anyway.  In any case, there is not much point persuing HBRBACKGROUND.

The only solution if you want 3D controls is to draw your own - either owner drawn or bitmap button (for buttons).  It is a pain, but if you want that much control over the drawing of control, then thats the path to take.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
elmo2Author Commented:
Is there a winapi equivalent to SetDialogBkColor. I'm not using MFC and am unable to.
0
RONSLOWCommented:
SetDialogBkColor just sets some values used by OnCtlColor - if you are not using MFC, just turn off 3D support and respond to the OnCtrlColor message

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.