【问题标题】:Get Backgroundcolor of themed TListView获取主题 TListView 的 Backgroundcolor
【发布时间】:2013-05-22 02:57:59
【问题描述】:

自 XE2 以来,有多个主题可用于您的应用程序。例如。 Carbon 将 TListView 的背景颜色更改为 gray

有没有办法得到这种颜色?
TListView.Color 返回 white,尽管背景是某种 gray

我尝试将 StyleServices.GetElementDetails 与这样的 sn-p 一起使用:

     var   lColor: TColor;
           lDetails: TThemedElementDetails;

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

但是GetElementColor失败并返回false。我使用了错误的参数吗?还是我的方法错了。

可以在这里找到可能的参数:
TThemedListView
TElementColor

谢谢。

P.S.:我也读过this post,但到目前为止答案对我没有帮助。

【问题讨论】:

    标签: delphi listview themes background-color


    【解决方案1】:

    获取已实现 StyleHook 的 TListView 的背景颜色:

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

    【讨论】:

    • 谢谢!这似乎有效。将进行更多检查并很快接受
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多