5

很容易检查节点是否可见。但我不知道如何正确定义屏幕上显示的节点。我只能这样发现:

BottomNode := Tree.BottomNode;
Node := Tree.TopNode;

IdBottomNode := Tree.AbsoluteIndex(BottomNode);

while Tree.AbsoluteIndex(Node) <> IdBottomNode do
begin
  Node := Node.NextSibling;
  if not Assigned(Node) then
    Break;
end;

(代码不检查)

但我认为这是相当粗糙的方式。可能有更准确的方法吗?

4

1 回答 1

14

您可以编写如下函数。那里的Tree参数指定虚拟树,Node是您要检查其是否可见的节点,Column可选参数是列的索引,如果您需要确定节点甚至列在客户端矩形中是否可见:

function IsNodeVisibleInClientRect(Tree: TBaseVirtualTree; Node: PVirtualNode;
  Column: TColumnIndex = NoColumn): Boolean;
begin
  Result := Tree.IsVisible[Node] and
    Tree.GetDisplayRect(Node, Column, False).IntersectsWith(Tree.ClientRect);
end;

但也许有更直接的方法......

于 2014-03-10T10:59:39.263 回答