9

Some components paint their color with the Color property setting even when vcl,styles are used. So when using a Metro dark style (nearly black) and a components color is set to clWindow the components color does not match the style. Is there a way to get the forms background color when using a vcl.style so that the color property of a component can be set to match the forms styled background color?

The color can be obtained by loading the style in the style designer, but I'd like to get the color value at runtime.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Bill
  • 2,993
  • 5
  • 37
  • 71
  • I know this is an old question, but for those that come across it like I just did, this [link](https://theroadtodelphi.com/2012/02/06/changing-the-color-of-edit-controls-with-vcl-styles-enabled/) might be an alternate solution to solve the actual problem of some controls not showing the correct color. But looks to be a lot more work. – Toby Mar 26 '21 at 21:16

2 Answers2

17

You can use the GetSystemColor function passing the proper system color constant to get

for example to get the background color of a TEdit component use

TStyleManager.ActiveStyle.GetSystemColor(clWindow)

And to get the default background color of a form try

TStyleManager.ActiveStyle.GetSystemColor(clBtnFace)
RRUZ
  • 134,889
  • 20
  • 356
  • 483
1

Also you can use :

StyleServices.GetStyleColor(scWindow)
S.MAHDI
  • 1,022
  • 8
  • 15
  • If custom styles is selected (project options) then this method is correct answer, otherwise use @RRUZ answer. Check for system style or custom style with `StyleServices.IsSystemStyle` – SAMPro Jul 27 '19 at 08:03