Virtual StringTree: how to determine if node text is fully displayed?

When TVirtualStreeTree.HintMode = hmTooltip, the text node will become the tooltip text when the mouse hangs over the node and the column where the node text does not display completely. But I have to set HintMode = hmHint so that I can provide different hint text in an even handler based on the position of the current mouse cursor, and in this HintMode the hint text is not generated automatically.

My question is how to find out if the text of a node is shown completely or not, so that I know if I should provide the text node or an empty string as the hint text?
Thank.

+3
source share
2

TBaseVirtualTree.GetDisplayRect, node. Unclipped . TextOnly 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;

, node, .

+1

, . cm_HintShow hmTooltip.

NodeRect := GetDisplayRect(HitInfo.HitNode, HitInfo.HitColumn, True, True, True);
BottomRightCellContentMargin := DoGetCellContentMargin(HitInfo.HitNode, HitInfo.HitColumn
, ccmtBottomRightOnly);

ShowOwnHint := (HitInfo.HitColumn > InvalidColumn) and PtInRect(NodeRect, CursorPos) and
  (CursorPos.X <= ColRight) and (CursorPos.X >= ColLeft) and
  (
    // Show hint also if the node text is partially out of the client area.
    // "ColRight - 1", since the right column border is not part of this cell.
    ( (NodeRect.Right + BottomRightCellContentMargin.X) > Min(ColRight - 1, ClientWidth) ) or
    (NodeRect.Left < Max(ColLeft, 0)) or
    ( (NodeRect.Bottom + BottomRightCellContentMargin.Y) > ClientHeight ) or
    (NodeRect.Top < 0)
  );

ShowOwnHint , node . .

, DoGetCellContentMargin , . , , ; OnBeforeCellPaint, (0, 0) .

HitInfo GetHitTestInfoAt.

0

Source: https://habr.com/ru/post/1729173/


All Articles