【问题标题】:Virtual TreeView selection width with toUseExplorerTheme使用 toUseExplorerTheme 的虚拟 TreeView 选择宽度
【发布时间】:2013-12-17 15:03:10
【问题描述】:

当我在TVirtualStringTree.PaintOptions 中使用toUseExplorerTheme 时,它会像这样绘制选择:

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

我希望它看起来像这张图片(someone else's project,使用 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];

【问题讨论】:

  • 多选时边缘参差不齐?哎呀......我猜味道不同,但它看起来,嗯......不整洁? +1 不过是一个很好的问题。
  • @Marjan,多样性是生活的调味品 :-)
  • @MarjanVenema 另一种选择是跨越整个宽度的资源管理器样式选择,但是很难/不可能在选择之外单击以取消选择全部。无论如何,我喜欢衣衫褴褛的右边缘。
  • 不用担心。虽然你可能会因此而在User Experience 上被激怒:-)

标签: delphi delphi-xe2 virtualtreeview


【解决方案1】:

对不起,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;

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

【讨论】:

  • @Joachim,哇,真快。但是,您能否也对DrawThemedFocusRect 嵌套过程执行类似操作?因为昨天很忙,所以今天准备提交一个问题。谢谢你,对这个问题深表歉意!
  • 谢谢。我在使用 Virtual TreeView 的第一个小时就发现了这一点,我不敢相信我发现了一个没有人注意到的错误!事实证明我这次错了 ;-) 不确定我的问题是否值得这么多的赞成票……虚拟树视图必须是一场噩梦,要测试这么多可配置的选项。
  • @TLama:也为 r587 中的 DrawThemedFocusRect() 完成。您介意查看代码更改吗?
猜你喜欢
  • 2014-07-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 2018-08-25
  • 2010-11-08
  • 1970-01-01
  • 2023-03-24
相关资源
最近更新 更多