从XE2开始,有几个主题可用于您的应用程序.例如.除了其他东西之外,将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;
但是GetElementColorfails并返回false.我使用了错误的参数吗?或者我的方法是错的.
可以在这里找到可能的参数:
TThemedListView
TElementColor
谢谢.
P.S.:我也读过this post但到目前为止答案对我没有帮助.
最佳答案 要获得已实现StyleHook的TListView的背景颜色:
uses Vcl.Themes;
var Color : TColor;
Color := StyleServices.GetStyleColor(scListView);