Returns information about the location of a point relative to the client area of the tree view control.
function GetHitTestInfoAt(X, Y: Integer): THitTests;
Description
Call GetHitTestInfoAt to determine what portion of the tree view, if any, sits under the point specified by the X and Y parameters. For example, use GetHitTestInfoAt to provide feedback about how to expand or collapse nodes when the mouse is over the relevant portions of the tree view.
GetHitTestInfo returns a THitTests type. This set describes the possible tree view elements under the mouse.
var
AnItem: TTreeNode;
AttachMode: TNodeAttachMode;
HT: THitTests;
begin
if TreeView1.Selected = nilthen Exit;
HT := TreeView1.GetHitTestInfoAt(X, Y);
AnItem := TreeView1.GetNodeAt(X, Y);
if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then
begin
if (htOnItem in HT) or (htOnIcon in HT) then AttachMode := naAddChild
else if htNowhere in HT then AttachMode := naAdd
else if htOnIndent in HT then AttachMode := naInsert;
TreeView1.Selected.MoveTo(AnItem, AttachMode);
end;
end;