Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Backgroundcolor of themed TListView

Since XE2, there are several themes that can be used for your application. E.g. Carbon that changes the background color of the TListView to gray besides other things.

Is there any way to get this color?
TListView.Color returns white altough the background is some kind of gray.

I tried using StyleServices.GetElementDetails with a snippet like this:

     var   lColor: TColor;
           lDetails: TThemedElementDetails;

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

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

The possible parameters can be found here:
TThemedListView
TElementColor

Thank you.

P.S.: I also read this post but the answer didn't help me so far.

like image 263
torno Avatar asked Oct 05 '22 00:10

torno


1 Answers

To get the background color of the TListView that has a StyleHook implemented :

uses Vcl.Themes;

var Color : TColor; 
Color := StyleServices.GetStyleColor(scListView);
like image 195
Peter Avatar answered Oct 12 '22 06:10

Peter