使用toUseExplorerTheme的虚拟TreeView选择宽度

Ian*_*dby 7 delphi virtualtreeview delphi-xe2

当我使用toUseExplorerThemeTVirtualStringTree.PaintOptions它绘制这样的选择:

选择的例证与toUseExplorerTheme

请注意,选择从控件的左侧延伸到任何节点标题的最右侧范围的位置; 选择的宽度都相同.

我希望它看起来像这个图像(其他人的项目,使用Virtual TreeView),其中选择仅涵盖节点标题的文本:

在此输入图像描述

除非Virtual TreeView中有回归(我使用5.2.2),否则这一定是可能的,但我找不到正确的选项组合.

这是我的设置代码:

fTree := TVirtualStringTree.Create(Self);
fTree.Parent            := Self;
fTree.Align             := alClient;

fTree.OnGetText         := TreeGetText;
fTree.OnInitNode        := TreeInitNode;
fTree.OnInitChildren    := TreeInitChildren;
fTree.OnChange          := TreeSelectionChange;
fTree.RootNodeCount     := 1;
fTree.DrawSelectionMode := smBlendedRectangle;

fTree.TreeOptions.PaintOptions     := fTree.TreeOptions.PaintOptions
                                      + [toUseExplorerTheme];
fTree.TreeOptions.SelectionOptions := fTree.TreeOptions.SelectionOptions
                                      + [toMultiSelect];
Run Code Online (Sandbox Code Playgroud)

TLa*_*ama 6

对不起,that was my fault.我建议的陈述this issue应该是:

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;
Run Code Online (Sandbox Code Playgroud)

这同样适用于下一个嵌套过程DrawThemedFocusRect.该修复程序现已提交给revision r587,因此请更新您的虚拟树视图.感谢@joachim的合作!

  • 我刚刚在修订版586中提交了修正后的修复程序. (2认同)