Link to home
Start Free TrialLog in
Avatar of jerm
jerm

asked on

Colored Buttons

How do you set the background color of a button in a dialog?

I have tried to override the WM_CTLCOLOR message to no avail.  I have also tried obtaining the devices context of an individual button control again with no results.  I have even tried creating a subclass that is attached to the control whereby I can override certain messages for that control.  I am still stuck with grey buttons.  Please help.
Avatar of thresher_shark
thresher_shark

If you are using MFC, go here:

http://www.codeguru.com/buttonctrl/index.shtml

It contains an excellent class for changing button colors along with a great description.  I highly recommend it.
> I have tried to override the WM_CTLCOLOR message to no avail.  

Don't even try.  Microsoft has 'by design' not allowed you to change your colors by any 'traditional' methods.  You can change any controls colors except buttons.  (sigh...)

They want you to use only CBitmapButton, but as thresh has so accurately pointed out, codeguru does have some workarounds.

Phillip
Look at this; TN062: Message Reflection for Windows Controls
Nope! Sorry! I hope you didn't believe what you read in TN062!  It won't work for buttons!
ASKER CERTIFIED SOLUTION
Avatar of AnthonyJ
AnthonyJ

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
AnthonyJ - This question has clearly been abandoned, the questioner has never even commented.  You should try to refrain from answering questions such as this.
Besides, the answers that we gave proves that the answer is incorrect anyway.  There is no way to change the color of a bitmap without drawing it manually or using a CBitmapButton!

Phillip
Agreed.  AnthonyJ - You should have read the comments too.
Oops. Good advice. I'll look before I leap next time. I should have known my 'solution' would not work in all cases. Anyway thanks for the kick up the arse.
Hehe, just thought you ought to know. :-)
AnthonyJ,

Just a pet pieve.  Its probably more than naught that some people answer old questions with just a 'huh' or a 'wake up' and actually get the points for it.  If this person doesn't respond within x number of days, you get the points.  I'm sure thresh has had it done to him many a times. (just like I have) :)

Phillip
Yep, I have.

In fact, get this, Answers2000 does this!  nietod and I were trying to help someone in the C++ programming section, but after a few days of no response we just forgot about it.  Then, about two weeks later I submitted a comment that said "Are you still there?  We can help."

Then, about a four days later (with no activity) Answers2000 comes in and submits "Have you died?  Or maybe nietod's Jul 31 comment put you off ?  This is a wake up call ?"

In case you want to see the whole question/comment thing, go here:

https://www.experts-exchange.com/Q.10068386

So don't worry, at least your answers are meaningful.  Answers2000 seems to be in it for the points.  :-(
:) :) :) :)

He's done it to me three times already!!! Got a 200 and a 150 from me!!  Definitely unemployed.  :)

Thanks for the complement.

Phillip

Avatar of jerm

ASKER

Sorry I didn't close this discussion earlier.