Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define that node of TVirtualStringTree is presented on screen?

It's easy to check that node is visible. But I don't know how to rightly define that node is presented on screen. I can find out only so:

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;

(code without checking)

But I think it is rather rough way. May be is there more accurate way?

like image 770
Dmitrii_Demin Avatar asked Mar 10 '14 10:03

Dmitrii_Demin


1 Answers

You may write a function like follows. The Tree parameter there specifies the virtual tree, the Node is the node for which you want to check if it's visible, and the Column optional parameter is the index of a column if you would need to determine whether the node and even column is visible in client 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;

But maybe there's a more straightforward way...

like image 76
TLama Avatar answered Sep 21 '22 03:09

TLama