虚拟StringTree:如何确定节点文本是否完整显示? [英] Virtual StringTree: How to determine if the node text is completely shown?

查看:66
本文介绍了虚拟StringTree:如何确定节点文本是否完整显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当TVirtualStreeTree.HintMode = hmTooltip时,当鼠标悬停在未完全显示节点文本的节点和列上时,节点文本将成为提示文本.但是我必须设置HintMode = hmHint,以便我可以在偶数处理程序中根据当前鼠标光标所在的位置提供各种提示文本,并且在该HintMode中不会自动生成提示文本.

我的问题是如何知道节点文本是否完整显示,所以我应该提供节点文本或空字符串作为提示文本吗?
谢谢.

When TVirtualStreeTree.HintMode = hmTooltip, the node text will become the hint text when the mouse is hovered over a node and column where the node text is not completely shown. But I have to set HintMode = hmHint, so that I can in the even handler supply various hint text based on the position the current mouse cursor is, and in that HintMode the hint text is not generated automatically.

My question is how to know if the a node text is shown completely or not, so that I know should I supply the node text or empty string as the hint text?
Thanks.

推荐答案

您可以调用TBaseVirtualTree.GetDisplayRect来确定节点的文本边界.根据Unclipped参数,它将为您提供完整或实际的文本宽度. TextOnly应该设置为True:

You can call TBaseVirtualTree.GetDisplayRect to determine the text bounds of a node. Depending on the Unclipped parameter, it will give you the full or actual text width. TextOnly should be set to True:

function IsTreeTextClipped(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean;
var
  FullRect, ClippedRect: TRect;
begin
  FullRect := Tree.GetDisplayRect(Node, Column, True, True);
  ClippedRect := Tree.GetDisplayRect(Node, Column, True, False);
  Result := (ClippedRect.Right - ClippedRect.Left) < (FullRect.Right - FullRect.Left);
end;

请注意,如果尚未初始化节点,该函数将隐式初始化节点.

Note that the function will implicitly initialize the node if it's not been initialized yet.

这篇关于虚拟StringTree:如何确定节点文本是否完整显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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