VirtualTreeView with UseExplorerThemes [英] VirtualTreeView with UseExplorerThemes

查看:182
本文介绍了VirtualTreeView with UseExplorerThemes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现使用Option toUseExplorerTheme可以为VirtualStringTree生成一个不错的选择矩形。但是,如果设置了选项toGridExtensions并且树中有多个列,则不会为内部单元格绘制选择的垂直边框,并且圆角也将丢失。只有最左边和最右边的列的最外边缘和角才能正确绘制。它看起来像在最外面的列之间绘制选择矩形,并且未选择的列的背景只是在选择矩形上绘制。

I just discovered that using the Option toUseExplorerTheme allows to produce a nice selection rectangle for a VirtualStringTree. However, if the Option toGridExtensions is set and there are several columns in the tree, the vertical border of the selection is not drawn for the inner cells, and the rounded corners are missing as well. Only the outermost edges and corners of the left- and right-most columns are drawn correctly. It looks as if the selection rectangle is drawn between the outermost columns and the background of the non-selected columns is just drawn over the selection rectangle.

关闭toGridExtensions会导致一个正确的选择矩形,但我更喜欢启用它,因为只能通过在标准模式下单击文本来选择单元格(

Turning off the toGridExtensions results in a correct selection rectangle, but I prefer to have it on because a cell can only be selected by clicking on the text in the standard mode (not by clicking on the empty space next to the text).

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

The issue occurs with Delphi 7 and XE2, and probably also with other versions.

要重现在表单中添加一个TVirtualStringTree,请显示头文件,为标题添加几列,并激活选项toGridExtensions(MiscOptions),toUseExplorerTheme(PaintOptions),toExtendedFocus(SelectionOptions),运行程序并单击任何单元格。

To reproduce add a TVirtualStringTree to a form, show the header, add several columns to the header, and activate the options toGridExtensions (MiscOptions), toUseExplorerTheme (PaintOptions), toExtendedFocus (SelectionOptions), run the program and click on any cell.

推荐答案

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

In my view it's a bug, because who would like to have a selection like this:

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

To fix it in a Virtual Tree View code (in my case v.5.1.4), go to the TBaseVirtualTree.PrepareCell method (in my case line 25802) and check this nested procedure code (comments are mine):

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;

要修复此问题,请以这种方式修改代码:

To fix this issue modify the code this way:

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 嵌套过程。

The same applies also to the next DrawThemedFocusRect nested procedure.

我已将此问题报告为 Issue 376 ,这在 修订版r587

I have reported this problem as Issue 376, which is fixed in revision r587.

这篇关于VirtualTreeView with UseExplorerThemes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆