+1  A: 

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.

TOndrej
Thank you TOndrej, your code worked like a charm! I tried GetDisplayRect but I didn't notice we can accomplish this task by using this function alone!
Edwin
A: 

You can use what the tree control itself uses. Here's an excerpt from the cm_HintShow message handler for single-line nodes when hmTooltip mode is in effect.

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)
  );

If ShowOwnHint is true, then you should return the node's text as the hint text. Otherwise, leave the hint text blank.

The main obstacle with using that code is that DoGetCellContentMargin is protected, so you can't call it directly. You can either edit the source to make it public, or you can duplicate its functionality in your own function; if you aren't handling the OnBeforeCellPaint event, then it always returns (0, 0) anyway.

The HitInfo data comes from calling GetHitTestInfoAt.

Rob Kennedy
Hi Rob, sorry, I didn't try this since TOndrej's code worked, thank you all the same!
Edwin