tor*_*rno 5 delphi listview themes background-color
从XE2开始,有几个主题可以用于您的应用程序。例如Carbon,除了其他功能外,还将TListView的背景色更改为灰色。
有什么办法得到这种颜色吗?
TListView.Color返回的全部是白色,而背景是某种灰色的。
我尝试将StyleServices.GetElementDetails与如下代码段一起使用:
var lColor: TColor;
lDetails: TThemedElementDetails;
if StyleServices.Enabled then
begin
lDetails := StyleServices.GetElementDetails(tlListviewRoot);
StyleServices.GetElementColor(lDetails, ecFillColor, lColor);
end;
Run Code Online (Sandbox Code Playgroud)
但是GetElementColor失败并返回false。我使用了错误的参数吗?还是我的方法是错误的。
可能的参数可以在这里找到:
TThemedListView
TElementColor
谢谢。
PS:我也读了这篇文章,但到目前为止,答案对我没有帮助。
要获取实现了 StyleHook 的 TListView 的背景颜色:
uses Vcl.Themes;
var Color : TColor;
Color := StyleServices.GetStyleColor(scListView);
Run Code Online (Sandbox Code Playgroud)