Solved

Colored Buttons

Posted on 1998-08-31
14
218 Views
Last Modified: 2010-04-02
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.
0
Comment
Question by:jerm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +2
14 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171678
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.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1171679
> 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
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1171680
Look at this; TN062: Message Reflection for Windows Controls
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:psdavis
ID: 1171681
Nope! Sorry! I hope you didn't believe what you read in TN062!  It won't work for buttons!
0
 

Accepted Solution

by:
AnthonyJ earned 50 total points
ID: 1171682
Capture this message at the window's parent. It is here that the control's colours can be changed. Unless you check the child control's window id,all the child controls of that type (LISTBOX, COMBOBOX, etc) also get that colour change.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171683
AnthonyJ - This question has clearly been abandoned, the questioner has never even commented.  You should try to refrain from answering questions such as this.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1171684
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
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171685
Agreed.  AnthonyJ - You should have read the comments too.
0
 

Expert Comment

by:AnthonyJ
ID: 1171686
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.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171687
Hehe, just thought you ought to know. :-)
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1171688
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
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171689
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:

http://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.  :-(
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1171690
:) :) :) :)

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

Thanks for the complement.

Phillip

0
 

Author Comment

by:jerm
ID: 1171691
Sorry I didn't close this discussion earlier.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question