0

I am developing a GUI application using Embarcadero VCL c++ IDE for windows OS. As part of this project, I have to change color of button with respect to an external state. I understood that windows32 API will not allow to change the color of button. Could you please suggest me, how to change button color?

1
  • You might want to tag this with winapi or something so people know what API you're working with.
    – Cornstalks
    Feb 22, 2013 at 2:25

1 Answer 1

0

Do you wish to change the background-colour of the button, or the text-colour of it?

Since windows has used visual themes for some time now, if you have commctrl loaded and include a manifest file, the button will be drawn using the default (current) theme.

Options I can see include (a) custom-drawing the background (b) changing the text-colour in the normal draw process (c) drawing the button without a theme (i.e drawing a 'flat' button).

You could simply draw a bitmap-button, changing the bitmap depending on the state of the button. You could also use a single bitmap, tinting it using the HSL or HSV colour-space, depending on the state.

As for the flat type of button, I think you can probably change it's background-colour in much the same way as you can change the colour of the text - by intervening during the standard draw process and changing the colour from 3D_FACE (or whatever it is, I forget) to whatever you'd like.

If you look at the calculator included with windows XP, you can see an example of changing the text colour.

CodeProject.com likely has a stack of articles that would help in this endeavour. :)

1
  • I wish to change the back-ground colour (NOT TEXT) of the button. I created small coloured bitmaps and tried to show it on bitmap button. But, this bitmap image not covering total button. I will look into your suggestions. once again thanks for your reply.
    – srvolatile
    Feb 25, 2013 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.