Topic: Change Button Text Color Problem

Hello MVD Fans,

How to change the text color of button ? ? ?

I try with this code

Form1.Button1.Font.Color := clRed;

And this code

Form1.Button1.Font.Color := RGB(255, 0, 0);

But no one of them change the color of button text !

Life is like a school;
One can learn and graduate or stay behind.

Re: Change Button Text Color Problem

Hi FMR,
If you use 'Styles', then this is just a single line of code in the script to change the colour (thanks to Sparrow for this tip).  Have a look at the attachment.
But if you're not using 'Styles', I don't know of any way that this can be easily done (if at all).
Regards,
Derek.

Post's attachments

Attachment icon change button color.zip 445.85 kb, 79 downloads since 2025-07-11 

Re: Change Button Text Color Problem

Hello derek,

Thank you and 'Sparrow ' this is will help, I read now on Lazarus IDE form this problem caused by Windows limitation, we can use same code on Linux without problem

Life is like a school;
One can learn and graduate or stay behind.

Re: Change Button Text Color Problem

Example of a color button

Post's attachments

Attachment icon change button color.zip 447.66 kb, 72 downloads since 2025-07-11 

Destiny

5 (edited by FMR 2025-07-12 14:55:23)

Re: Change Button Text Color Problem

The only effect can do on button is font style (Bold, Italic, Underline and StrikeOut)

I used a Bold for button feature as (Active / Inactive)

Life is like a school;
One can learn and graduate or stay behind.

Re: Change Button Text Color Problem

Hi all

You can take the simplest style "Windows10". Small in size and with minimal color change. Then as Derek showed in the example.

Re: Change Button Text Color Problem

Another possibility...that I learned about here on the forum.

Post's attachments

Attachment icon change button color3.zip 449.49 kb, 66 downloads since 2025-07-12 

Roberto Alencar

8 (edited by Destiny 2025-07-12 05:20:35)

Re: Change Button Text Color Problem

This is the simplest solution I found, at least you can customize your buttons.

Destiny

Re: Change Button Text Color Problem

Bold as Active / Regular as InActive

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
If (Form1.Button1.Font.Style = fsBold) Then
    Begin
    Form1.Button1.Font.Style := 0;
    Form1.Label1.Caption := 'Button 1 : InActive (Regular)'; // Replace with InActive Scenario code.
    End Else
    Begin
    Form1.Button1.Font.Style := fsBold;
    Form1.Label1.Caption := 'Button 1 : Active (Bold)'; // Replace with Active Scenario code.
    End;
end;
Post's attachments

Attachment icon Button_Effect.zip 3.77 kb, 61 downloads since 2025-07-12 

Life is like a school;
One can learn and graduate or stay behind.

Re: Change Button Text Color Problem

this one is good too

Post's attachments

Attachment icon botão_panel.zip 369.59 kb, 66 downloads since 2025-07-12 

Roberto Alencar

Re: Change Button Text Color Problem

Thought there was no point in starting a new post as this is also color / colour related, Question I am having trouble with Text and Panels changing colours when using Styles, When using default it all works fine.

Post's attachments

Attachment icon No Colour when Using Styles.zip 1006.34 kb, 38 downloads since 2025-08-22 

Re: Change Button Text Color Problem

Hi,
When using styles, all elements take the colour settings of that 'style' by default.
If you want to alter a specific colour setting for any element, you first need to switch off the 'style' for that particular element.
For example,
form1.label1.styleelement := nil;
These commands can be put right at the end of your script between the final 'begin' and 'end'.
A couple of other things to note;
1.  this is also the way that you can 'turn off' the standard windows menu when using 'styles'.
2.  you can just select a 'style' from the 'styles' option when in the development window rather than writing a script.
3.  using 'styles' actually enables you to use different colours for your button captions - something that isn't possible with using the 'standard' (non styles) default display (thanks to Sparrow for this tip).
Please have a look at the attachment
Regards,
Derek.

Post's attachments

Attachment icon No Colour when Using Styles fixed.zip 1.09 mb, 46 downloads since 2025-08-22 

Re: Change Button Text Color Problem

Hi Derek


According to https://docwiki.embarcadero.com/Librari … leElements the StyleElements property has three constant values:
seFont - 1
seClient - 2
seBorder - 4.
MVD accepts only numeric constants.
Using constants or combinations of constants, you can turn off/on the effect of the style on the component elements.
seFont - The control uses the font defined in the style.
seClient - The control uses the background color or image of the style.
seBorder - The control uses the border and scroll bars of the style.
By default, the value of StyleElements = 7 (everything is on), respectively 0 - everything is off.
And you are indeed right, for some components this is the only way to change the color.
Unfortunately, TableGrid and its scroll bars are not sensitive to styles and, accordingly, do not support StyleElements.