如何定义TVirtualStringTree的节点显示在屏幕上? [英] How to define that node of TVirtualStringTree is presented on screen?

查看:108
本文介绍了如何定义TVirtualStringTree的节点显示在屏幕上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很容易检查节点是否可见.但是我不知道如何正确定义该节点显示在屏幕上.我只能这样找到:

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;

(不检查代码)

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

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

推荐答案

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

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...

这篇关于如何定义TVirtualStringTree的节点显示在屏幕上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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