How make a firemonkey button with transparent graphic, and make it the default style
-
03-12-2019 - |
Question
With firemonkey I'm lost in how do some basic stuff.
I already know that I need to put a TImageControl inside the TButton to show a image.
However, the TImageControl is show with a border and a white background. I load inside a ico and/or png and wanna show it transparent, and wanna this for the whole app.
What are the steps for do this?
Solution
Try TImage
instead of TImageControl
. TImage is transparent by default. Of course, if your image isn't rectangular, you'll want to load an image that supports alpha channel, such as a PNG image.
If you insist on a TImageControl, right-click on it, select "Edit Custom Style..." and on the background TRectangle, set it's Fill color from claWhite
to claNull
and click Apply and Close
. For any additional TImageControl, set its StyleLookup property to the same.
You'll also want to turn off the HitTest property of the image control.
OTHER TIPS
My TBitmapSpeedButton component may provide a ready rolled solution for what you're trying to achieve. If not, the blog post about how I created it will almost certainly help.