In my Delphi VCL Form Application, I have to change the background color of a TButton. Is there a way to apply this change without using third-party components?
Thanks.
In my Delphi VCL Form Application, I have to change the background color of a TButton. Is there a way to apply this change without using third-party components?
Thanks.
You can't change the color of a TButton
component directly, instead you must use a third-party component or owner draw the button (BS_OWNERDRAW
).
WM_DRAWITEM
. –
Regulus Original source: https://engineertips.wordpress.com/2020/07/21/delphi-button-background-color/
Nice tip, thank you, Xel Naga!
You can also place an image on the panel, to make your button even nicer. Here I’ve added an image of a Yellow- Glass- button. To get the rounded corners, you shape the panel like this >>
SetWindowRgn(Panel1.Handle, CreateRoundRectRgn(0, 0, Panel1.Width, Panel1.Height, 65, 40), True);
Next level after that, you can add 3 more images (on top of each-other) for button states: Mouse Over (OnMouseEnter), Button Pressed (OnMouseDown) and Button Disabled. Just change the Visible state of the images to reveal the one you want to see...
© 2022 - 2024 — McMap. All rights reserved.