Get Backgroundcolor of thematic TListView

There are several themes with XE2 that can be used for your application. For instance. Carbon that changes the background color of a TListView to gray, among other things.

Is there any way to get this color?
TListView.Color returns white if the background is somehow gray.

I tried using StyleServices.GetElementDetails with the following snippet:

var lColor: TColor; lDetails: TThemedElementDetails; if StyleServices.Enabled then begin lDetails := StyleServices.GetElementDetails(tlListviewRoot); StyleServices.GetElementColor(lDetails, ecFillColor, lColor); end; 

But GetElementColor fails and returns false. Am I using the wrong parameter? Or my approach is wrong.

Possible parameters can be found here:
TThemedListView
TElementColor

Thanks.

PS: I also read this post , but the answer has not helped me yet.

+4
source share
1 answer

To get the background color of a TListView with a StyleHook implementation:

 uses Vcl.Themes; var Color : TColor; Color := StyleServices.GetStyleColor(scListView); 
+2
source

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


All Articles