加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 使用UseExplorerThemes的VirtualTreeView

发布时间:2020-12-15 10:03:54 所属栏目:大数据 来源:网络整理
导读:我刚刚发现使用Option toUseExplorerTheme可以为VirtualStringTree生成一个很好的选择矩形.但是,如果设置了Option toGridExtensions并且树中有多个列,则不会为内部单元格绘制选区的垂直边框,并且也会丢失圆角.仅正确绘制左侧和最右侧列的最外边缘和角.看起来
我刚刚发现使用Option toUseExplorerTheme可以为VirtualStringTree生成一个很好的选择矩形.但是,如果设置了Option toGridExtensions并且树中有多个列,则不会为内部单元格绘制选区的垂直边框,并且也会丢失圆角.仅正确绘制左侧和最右侧列的最外边缘和角.看起来好像选择矩形是在最外面的列之间绘制的,而非选定列的背景只是在选择矩形上绘制.

关闭toGridExtensions会产生一个正确的选择矩形,但我更喜欢打开它,因为只能通过单击标准模式中的文本来选择单元格(而不是单击文本旁边的空白区域).

Delphi 7和XE2会出现问题,也可能与其他版本一起出现问题.

要重现向表单添加TVirtualStringTree,显示标题,向标题添加多个列,并激活选项toGridExtensions(MiscOptions),toUseExplorerTheme(PaintOptions),toExtendedFocus(SelectionOptions),运行程序并单击任何单元格.

解决方法

在我看来这是一个错误,因为谁想要这样的选择:

要在虚拟树视图代码(在我的情况下为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,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,nil);
end;

你会得到这样的选择:

这同样适用于下一个DrawThemedFocusRect嵌套过程.

我已将此问题报告为Issue 376,已于revision r587修复.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读