在我看来,这是一个错误,因为谁想要这样的选择:
要在虚拟树视图代码中修复它(在我的情况下为 v.5.1.4),请转到TBaseVirtualTree.PrepareCell
方法(在我的情况下为第 25802 行)并检查此嵌套过程代码(评论是我的):
procedure DrawBackground(State: Integer);
begin
// here the RowRect represents the row rectangle and InnerRect the cell
// rectangle, so there should be rather, if the toGridExtensions is NOT
// in options set or the toFullRowSelect is, then the selection will be
// drawn in the RowRect, otherwise in the InnerRect rectangle
if (toGridExtensions in FOptions.FMiscOptions) or (toFullRowSelect in FOptions.FSelectionOptions) then
DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, RowRect, nil)
else
DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, InnerRect, nil);
end;
要解决此问题,请以这种方式修改代码:
procedure DrawBackground(State: Integer);
begin
// if the full row selection is disabled or toGridExtensions is in the MiscOptions, draw the selection
// into the InnerRect, otherwise into the RowRect
if not (toFullRowSelect in FOptions.FSelectionOptions) or (toGridExtensions in FOptions.FMiscOptions) then
DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, InnerRect, nil)
else
DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, RowRect, nil);
end;
你会得到这样的选择:
这同样适用于下一个DrawThemedFocusRect
嵌套过程。
我已将此问题报告为Issue 376
,已在revision r587
.