Jump to content
weabow

TButton : change backgroundcolor

Recommended Posts

Hi there,

I've now spend somme hours to try to change the Background Color of a TButton, or TSpeedButton, at run time. But no way !

 

An idea ?

Share this post


Link to post

TButton is a wrapper around a Windows control so doesn't natively support a custom color. To accomplish this, you could use TRzButton (from KSVC) and disable the ThemeAware property, then set its Color property.

Share this post


Link to post
2 hours ago, corneliusdavid said:

TButton is a wrapper around a Windows control

That is true only if its ControlType property is set to Platform. The default is Styled instead, in which case it is not a native Windows control.

(This is posted in an FMX group, not a VCL group)

Share this post


Link to post
7 minutes ago, Remy Lebeau said:

(This is posted in an FMX group, not a VCL group)

Good point; I often forget to look at which group the message is in.

Share this post


Link to post

Thanks a lot. I'de like to have a class inheriting from TButton, under FMX Crossplatform.

 

How may I set the controltype in this case ?

Share this post


Link to post
On 7/31/2024 at 9:45 AM, weabow said:

I've now spend somme hours to try to change the Background Color of a TButton, or TSpeedButton, at run time. But no way ! 

Embarcadero posted a blog article about that for TEdit, but the same approach should work for a TButton as well:

Edit Custom Style to change the background color of a FMX TEdit

6 hours ago, weabow said:

How may I set the controltype in this case ?

It is just a property like any other.  What is stopping you from setting it?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×