Is it possible to change the text color and the background color of a button or write them trough TextOut and DrawText?

Posted on 2004-06-26 15:49:08 by Marginais

maybe you can do it with a windows message - but I don't know how.

But you could subclass the button (surely you have already done it for the WM_COMMAND) and check for the WM_PAINT message.

Then, you can draw the whole button on your own and don't forward the message.

Posted on 2004-06-27 07:18:22 by ndn4u
You would have to do an owner draw button. Standard buttons are very difficult to color. I have an example of owner drawn buttons on my website, just press the www button at the bottom of this post and go to the GoAsm projects page, it's there somewhere.
Posted on 2004-06-27 07:26:52 by donkey
I wouldn't know about that for the moment, but try the following:

A bunch of misinformation :/

It's not tested, but give it a try :)

Posted on 2004-06-27 07:28:04 by JimmyClif
Btw: I always found it easier just to use Bitmaps with Buttons when something like special background or fonts were needed.

Check out this link : It's a demo on about using Bitmaps for Buttons.
Posted on 2004-06-27 07:38:53 by JimmyClif
Hi Jimmy,

WM_CTLCOLORBTN only works with owner draw buttons.

You can set the font of a normal button with WM_SETFONT however.
Posted on 2004-06-27 07:59:13 by donkey
Uh... Maybe I should really start reading winhlp before opening my trap :/
Posted on 2004-06-27 08:53:38 by JimmyClif

Uh... Maybe I should really start reading winhlp before opening my trap :/

Hi Jimmy,

You are certainly not the first to get caught by that message and defintitely will not be the last. The WM_CTLCOLOR messages are bizarre to say the least. WM_CTLCOLORSTATIC changes the color of checkbox buttons :confused:
Posted on 2004-06-27 13:45:08 by donkey
Woop. At least I changed my signature to the current one before I posted.
Posted on 2004-06-27 14:55:31 by JimmyClif
But how do I use WM_CTLCOLORBTN? I didn't get how to return the brush value to windows. Can you post an example?
Posted on 2004-06-27 15:33:05 by Marginais
Hi Marginais,

To return any value to Windows just put in EAX when your WndProc returns. As I said, WM_CTLCOLORBTN will probably not be what you are looking for but JimmyClif has posted an example above.
Posted on 2004-06-27 15:39:20 by donkey