Delphi 如何定义屏幕上显示的TVirtualStringTree节点?

Delphi 如何定义屏幕上显示的TVirtualStringTree节点?,delphi,delphi-xe2,virtualtreeview,tvirtualstringtree,Delphi,Delphi Xe2,Virtualtreeview,Tvirtualstringtree,很容易检查节点是否可见。但我不知道如何正确定义屏幕上显示的节点。我只能这样发现: BottomNode := Tree.BottomNode; Node := Tree.TopNode; IdBottomNode := Tree.AbsoluteIndex(BottomNode); while Tree.AbsoluteIndex(Node) <> IdBottomNode do begin Node := Node.NextSibling; if not Assigne

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

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;
BottomNode:=Tree.BottomNode;
节点:=Tree.TopNode;
IdBottomNode:=Tree.AbsoluteIndex(底部节点);
而Tree.AbsoluteIndex(节点)IdBottomNode
开始
Node:=Node.NextSibling;
如果未分配(节点),则
打破
结束;
(代码未经检查)


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

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

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;

但也许有一种更直接的方法…

谢谢!现在这是最好的方法,不客气!我做了一个小小的改变。标题中不需要有任何列。但正如我所说,也许有一些现成的方式。