Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of TButton?

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.

like image 486
user3535015 Avatar asked Apr 15 '14 11:04

user3535015


People also ask

How do I change the color of a button?

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:".

How do you change the color of a button Excel?

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).

How do I change the color of a submit button in CSS?

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!


1 Answers

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

like image 67
Remy Lebeau Avatar answered Oct 02 '22 12:10

Remy Lebeau