VirtualStringTree.HotColor不与toHotTrack一起使用

问题描述 投票:1回答:1

我将toHotTrack添加到VST.TreeOptions.PaintOptions并将VST.Colors.HotColor更改为clGreen,但HotColor不适用于HotNode,只有节点的文本加下划线。

  1. 如何解决这个问题呢?
  2. 是否可以删除下划线并仅将HotColor应用于它?
delphi virtualtreeview tvirtualstringtree
1个回答
0
投票

Colors.HotColor用于改变Font.Color,而不是Brush.Color。使用toHotTrack只会更改Font.Color并将fsUnderLine添加到Font.Style,请参阅实施部分。

if (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) then
begin
  if not (tsUseExplorerTheme in FStates) then
  begin
    Canvas.Font.Style := Canvas.Font.Style + [fsUnderline];
    Canvas.Font.Color := FColors.HotColor;
  end;
end;

但是,它很容易改变,例如在OnBeforeCellPaint。如果你不想要fsUnderline,你需要从toHotTrack中删除TreeOptions.PaintOptions,在这种情况下不需要。

procedure VSTBeforeCellPaint(Sender: TBaseVirtualTree; TargetCanvas: TCanvas;
  Node: PVirtualNode; Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; 
  CellRect: TRect; var ContentRect: TRect);
begin
  if (CellPaintMode = cpmPaint) and (Node = vstStrom.HotNode) then
  begin
    TargetCanvas.Brush.Color := clGreen;
    TargetCanvas.FillRect(CellRect);
  end;
end;
© www.soinside.com 2019 - 2024. All rights reserved.