Jump to content
Andrew Spencer

Setting Font Color on certain controls

Recommended Posts

Why can I set the Font.Color property, in Delphi 7, for controls like TCheckBox (and descendents TDBCheckBox etc) TRadioGroup and get the expected result. But in Delphi 10.4.2 everything remains clWindowText (or clBlack).

 

TLabel.Font.Color works, but most other controls do not.

 

Have I really just not noticed this for the past few years!?

Edited by Andrew Spencer

Share this post


Link to post

If you use themes, don't be surprised.

Share this post


Link to post

If you enable Runtime Themes you delegate the drawing for some components to Windows and the colors from the Active Windows Theme is used. In ancient versions of Delphi this was done through XPManifest.

 

You can use VCL Styles to customize the drawing.

Share this post


Link to post
3 hours ago, Andrew Spencer said:

Why can I set the Font.Color property, in Delphi 7, for controls like TCheckBox (and descendents TDBCheckBox etc) TRadioGroup and get the expected result. But in Delphi 10.4.2 everything remains clWindowText (or clBlack).

 

TLabel.Font.Color works, but most other controls do not.

 

Have I really just not noticed this for the past few years!?

This is the style support at work. You can disable/override it on a control basis using the StyleElements property.

Share this post


Link to post
5 hours ago, Lajos Juhász said:

You can use VCL Styles to customize the drawing.

And also introduce large numbers of obscure bugs that will take forever to debug. 

  • Like 2

Share this post


Link to post

Or instead of dealing with the Vcl/Theme style you can easily put a label/panel next to a control and color it however you like and maybe add handler to simulate same behavior for mouse clicks. (Anchoring works great on that matter)

Edited by KodeZwerg

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×