我将toHotTrack
添加到VST.TreeOptions.PaintOptions
并将VST.Colors.HotColor
更改为clGreen
,但HotColor
不适用于HotNode
,只有节点的文本加下划线。
HotColor
应用于它?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;