首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VirtualTreeView与UseExplorerThemes

VirtualTreeView与UseExplorerThemes
EN

Stack Overflow用户
提问于 2013-09-26 13:59:52
回答 1查看 704关注 0票数 3

我刚刚发现,使用toUseExplorerTheme选项可以为VirtualStringTree生成一个很好的选择矩形。但是,如果设置了选项toGridExtensions,并且树中有几个列,则不会为内部单元格绘制所选内容的垂直边框,并且也缺少圆角。只有最左边和最右边的列的最外面的边缘和角是正确的。看起来,选择矩形是在最外层的列之间绘制的,而非选定列的背景只是绘制在选择矩形上。

关闭toGridExtensions会产生正确的选择矩形,但我更喜欢打开它,因为只有在标准模式下单击文本才能选择单元格(而不是单击文本旁边的空空间)。

这个问题发生在Delphi7和XE2上,可能也会出现在其他版本中。

若要复制向窗体添加TVirtualStringTree,请显示标题,向标头添加多个列,并激活选项toGridExtensions (MiscOptions)、toUseExplorerTheme (PaintOptions)、toExtendedFocus (SelectionOptions)、运行程序并单击任意单元格。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-26 14:23:40

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

要在虚拟树视图代码中修复它(在我的示例中是v.5.1.4),转到TBaseVirtualTree.PrepareCell方法(在我的例子中是第25802行)并检查这个嵌套的过程代码(注释是我的):

代码语言:javascript
复制
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;

若要解决此问题,请以下列方式修改代码:

代码语言:javascript
复制
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解决的。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19030376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档