How to get background color of forms using VCL.Styles

Some components color their color using the Color property, even when vcl uses styles. Therefore, when using the dark Metro style (almost black) and the color of the components set to clWindow, the color of the components does not match the style. Is there a way to get the background color of the forms using vcl.style so that the color property of the component can be set to match the color in the style style?

You can get the color by loading the style into the style constructor, but I would like to get the color value at runtime.

+4
source share
2 answers

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

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

 TStyleManager.ActiveStyle.GetSystemColor(clWindow) 

And to get the background color of the default shape, try

 TStyleManager.ActiveStyle.GetSystemColor(clBtnFace) 
+9
source

Also you can use:

 StyleServices.GetStyleColor(scWindow) 
0
source

Source: https://habr.com/ru/post/1499037/


All Articles