In "Borland" C++ Builder 6, how to change color of button (TButton
)?
I've tried in this way
button->Font->Color = clRed;
but it doesn't work.
All style elements in your HTML button tag should be placed within quotation marks. Type background-color: in the quotation marks after "style=". This element is used to change the background color of the button. Type a color name or hexadecimal code after "background-color:".
To change the BackColor of the button, (1) click on Alphabetic to see a list of button properties in alphabetical order. Then (2) select BackColor in the left column, and (3) click on the arrow in the right column to display the color options. Finally, (4) choose a color (from the Palette or System).
Target Specific ButtonsGo to the Style tab and scroll to the bottom of the survey preview. Click the HTML/CSS Editor link. Paste in the appropriate piece of CSS code from below in the field on the Custom CSS tab. Replace the hex color value (like #000000) with the color of your choice!
TButton
is a thin wrapper around a standard Win32 BUTTON
control, which gets its coloring from the OS, not the VCL. You cannot set the Color
for a standard TButton
. The Color
property exists only because it is inherited from a base class.
That being said, the Win32 BUTTON
does support a BS_OWNERDRAW
style. You can use SetWindowLong()
to enable it, then subclass the button to handle the WM_DRAWITEM
message so you can paint the button however you want.
Here is an example component that derives from TButton
and implements BS_OWNERDRAW
to expose working color properties: TColorButton
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With