Jump to content
alank2

TSpeedButton - how to change the background color

Recommended Posts

I've done enough searching to know that it is based on a bitmap; I even remember drilling down and opening a bitmap that looked like the source of how it figures out how to draw controls.

 

I am creating a number the TSpeedButton's programmatically and I have been using the StyleLookup="buttonstyle" which looks mostly like what I want except it has a grayish background which I need to change to a white background.

 

What is the easiest way to accomplish that?

Share this post


Link to post

Well, it's FMX, so you can change the style (creating a custom one or modifying existent)

Here I delete initial background, put a TRectangle (aligned contents), sending it background (control/background) and  set property stylename  to background too.

Advantage you can "easily" change color of a Trectangle.

Inconvenient :

    - if you want to use all other buttonstyles, you have to do the same thing !

    - if you use dark colors, take care of the fontcolor 

Notice, same as always, if you use it for all platforms change default style not the "Windows" default one

Capture_1.PNG

Share this post


Link to post

I right clicked it and created a custom style.  Then I found the background and edited NormalLink to change where it was pointed to to pointing to the middle of a white box so it would become white.

 

Are you saying you replaced the background TButtonStyleObject with a TRectangle?

 

Can the bitmap graphics that NormalLink points to be edited?  What if I wanted to add something to that bitmap?

Share this post


Link to post
16 hours ago, alank2 said:

Are you saying you replaced the background TButtonStyleObject with a TRectangle?

Yes, acting so even if you change stylebook at run time this custom style is independent

 

16 hours ago, alank2 said:

Can the bitmap graphics that NormalLink points to be edited? 

Yes, even if it's not so easy, you have to change about three PNG images (dpi necessity) .  I remember a video  by Sarina Dupont about using Adobe and Stencils to change colors

(see this tool) sorry, I don't found the link

and many others interventions (videos, blogs) about bitmap designer tool

Basically, using bitmap designer tool : save image 

 

, edit images with whatever tool you have, and then return to bitmap designer, load the new image (hoping this should not change regions defined, I never check this)

Yes, you should say : "but bitmap designer is for VCL" (VSF file) but it's easy to save it as a FMX style

16 hours ago, alank2 said:

What if I wanted to add something to that bitmap?

I guess increasing the size of the image, putting the desired drawing outside the already defined areas will do the trick

Capture_1.PNG

 

Edited by Serge_G

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

×