TVirtualStringTree& toUseExplorerTheme - 更改颜色选定项目和鼠标悬停

时间:2018-03-06 16:40:42

标签: delphi tvirtualstringtree

我使用TVirtualStringTree + toUseExplorerTheme + toThemeAware进行漂亮的显示。但我需要更改所选项目的颜色和悬停项目。 怎么办呢?

1 个答案:

答案 0 :(得分:0)

感谢大家! 解决了以下问题:

SelectionBlendFactor:= 0 toUseExplorerTheme + toThemeAware:= False

procedure MyForm.vtLogBeforeItemErase(Sender: TBaseVirtualTree;
  TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect;
  var ItemColor: TColor; var EraseAction: TItemEraseAction);

begin
  inherited;
  if not Assigned(Node) then
    Exit;

  EraseAction := eaColor;

  if not Odd(Node.Index) then
    ItemColor := $00FAF7F5
  else
    ItemColor := vtLog.Color;

  if vsSelected in Node.States then begin
    if vtLog.Focused then
      ItemColor := $00D6B693//$E1B959
    else
      ItemColor := $00E9E1D8;
  end
  else
    if vtLog.Focused and Assigned(vtLog.HotNode) and (vtLog.HotNode.Index = Node.Index)  then begin
      ItemColor := $00FBECDC;
    end;
end;

非常漂亮的绘画和工作。

相关问题