Board index » cppbuilder » The color of a button

The color of a button

Hi. How can I change the color of a TButton object in my form ?

A.V.

---------------------------------------------------
my pages for the programmer at:
www.hochfeiler.it/alvise

 

Re:The color of a button


Hello Alvise,
You have to set the Color property of the TButton
Try something like

Button1->Color=clRed; // this is not really a nice button color, but this
shall convain you that it works !

Where Button1 is the identifier of a TButton instance,
Note that you also can use the RGB macro to assign your own color values,
this gives
Button1->Color=(TColor) RGB(33,66,99);

If such coding tires you, you can do this at design-time by selecting the
button on you form, then picking up the wanted color in the object
inspector, at the row named Color.

Re:The color of a button


Hi Alvise.
Sorry, but you can't.  TButton does not support color changes.  Check out
Torry's web site and see if you can find a button that does:
www.torry.net

Quote
"Alvise Valsecchi" <alv...@hochfeiler.it> wrote in message

news:3A7AC10E.A4689DED@hochfeiler.it...
Quote

> Hi. How can I change the color of a TButton object in my form ?

> A.V.

> ---------------------------------------------------
> my pages for the programmer at:
> www.hochfeiler.it/alvise

Re:The color of a button


Thanks for your response. I did like you said:

Quote
> You have to set the Color property of the TButton
> Try something like

> Button1->Color=clRed; // this is not really a nice button color, but this
> shall convain you that it works !

but at compile time I get the following error:

"Controls::Tcontrol::Color" is not accessible

then, trying this:

Quote
> Note that you also can use the RGB macro to assign your own color values,
> this gives
> Button1->Color=(TColor) RGB(33,66,99);

I get the above message again. Furthermore:

Quote
> If such coding tires you, you can do this at design-time by selecting the
> button on you form, then picking up the wanted color in the object
> inspector, at the row named Color.

I CAN'T find Color in object inspector, this is why I posted the message
!

What is wrong with me ??? I use C++ Builder 3 professional.

Thanks for your help. A.V.

Re:The color of a button


TButton doesn't support custom coloring

Gambit

Quote
Alvise Valsecchi <alv...@hochfeiler.it> wrote in message

news:3A7AC10E.A4689DED@hochfeiler.it...
Quote
> Hi. How can I change the color of a TButton object in my form ?

Re:The color of a button


agir.soft wrote in <3a7acc44_2@dnews>...

Quote

> Hello Alvise,
> You have to set the Color property of the TButton
> Try something like

> Button1->Color=clRed; // this is not really a nice button color, but this
> shall convain you that it works !

This won't work, because the colour of a normal TButton can't be changed.
Windows paints these buttons, and always in the default colour for that.
That is why TButton doesn't publish a Color property.
--
Rudy Velthuis (TeamB)                http://delphi-jedi.org

Re:The color of a button


Quote
Alvise Valsecchi wrote:

> Hi. How can I change the color of a TButton object in my form ?

You can't change the color of the TButton but you can make a
panel that looks like a button by changing the BevelWidth property
to 2. You can also lower and raise the inner and outer bevels
as the user clicks on the button.

************************************
*      Blueprint Software          *
************************************
Thomas Oeser
Blueprint Software
http://www.blueprintsoftware.com.au

Re:The color of a button


Quote
> Hi. How can I change the color of a TButton object in my form ?

Use a another component. For buttons of every shape and size imaginable,
check out the ZieglerCollection, a shareware library of components:

http://www.zieglersoft.com

+=====================================================+
| Jonathan Arnold (mailto:jdarn...@buddydog.org)      |
|         Comprehensive C++Builder link site:         |
| http://www.buddydog.org/C++Builder/c++builder.html  |
+=====================================================+

Re:The color of a button


Quote
Thomas wrote:

> You can't change the color of the TButton but you can make a
> panel that looks like a button by changing the BevelWidth property
> to 2. You can also lower and raise the inner and outer bevels
> as the user clicks on the button.

Thanks Thomas ! Yours is a very good advice. Making a button using a
TPanel is better than using TButton. I can also change the shape of the
cursor to "HandPoint". I changed the BevelWidth property to 2, and add a
couple of statements in the OnClick handler:

a) first statement of the handler:

Panel1 -> BevelOuter -> bvLowered;

b) last statement of the handler:

Panel1 -> BevelOuter -> bvRaised;

Furthermore the "button" remains lowered during all the time that the
function is active.

Thanks again and regards. A.V.

Other Threads