delphi – 使用toUseExplorerTheme的虚拟TreeView选择宽度

前端之家收集整理的这篇文章主要介绍了delphi – 使用toUseExplorerTheme的虚拟TreeView选择宽度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在TVirtualStringTree.PaintOptions中使用toUseExplorerTheme时,它会像这样绘制选择:

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

我希望它看起来像这个图像(someone else’s project,使用Virtual TreeView),其中选择仅涵盖节点标题的文本:

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

这是我的设置代码

  1. fTree := TVirtualStringTree.Create(Self);
  2. fTree.Parent := Self;
  3. fTree.Align := alClient;
  4.  
  5. fTree.OnGetText := TreeGetText;
  6. fTree.OnInitNode := TreeInitNode;
  7. fTree.OnInitChildren := TreeInitChildren;
  8. fTree.OnChange := TreeSelectionChange;
  9. fTree.RootNodeCount := 1;
  10. fTree.DrawSelectionMode := smBlendedRectangle;
  11.  
  12. fTree.TreeOptions.PaintOptions := fTree.TreeOptions.PaintOptions
  13. + [toUseExplorerTheme];
  14. fTree.TreeOptions.SelectionOptions := fTree.TreeOptions.SelectionOptions
  15. + [toMultiSelect];

解决方法

对不起,that was my fault.我在 this issue建议的陈述应该是:
  1. procedure DrawBackground(State: Integer);
  2. begin
  3. // if the full row selection is disabled or toGridExtensions is in the MiscOptions,draw the selection
  4. // into the InnerRect,otherwise into the RowRect
  5. if not (toFullRowSelect in FOptions.FSelectionOptions) or (toGridExtensions in FOptions.FMiscOptions) then
  6. DrawThemeBackground(Theme,PaintInfo.Canvas.Handle,TVP_TREEITEM,State,InnerRect,nil)
  7. else
  8. DrawThemeBackground(Theme,RowRect,nil);
  9. end;

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

猜你在找的Delphi相关文章