HitTest(Pt: IPoint; Var Hit: HitTestResult): ITreeListNode;
Pt. The point, at which component element must be obtained.
Hit. The parameter, which will contain additional information after the method is executed.
The HitTest method checks if there is an element in the specified point of client component area and returns check result.
The HitTest method is an extension of the GetItemAt method.
If the Pt point is in the element area (the whole line is taken into account: indent area, state icon, icon, element text in any column and in the free area right from text), the method returns parameters of the element or the method returns Null.
The variable that will be passed as the Hit parameter will also contain the component area, in which the Pt point is located.
NOTE. The GetItemAt method is not supported by the TreeCombo, MetabaseTreeCombo components that inherit from the ITreeControl component.
Executing the example requires a form and the TreeList component named TreeList1 on it. The specified procedure is set as the OnMouseDown event handler of the TreeList1 component.
Sub TreeList1OnMouseDown(Sender: Object; Args: IMouseClickEventArgs);
Var
Node: ITreeListNode;
Result: HitTestResult;
s: String;
Begin
Node := TreeList1.HitTest(Args.pPoint, Result);
Select Case Result
Case HitTestResult.Nowhere: s := "Nowhere";
Case HitTestResult.OnItemIcon: s := "OnItemIcon";
Case HitTestResult.OnItemLabel: s := "OnItemLabel";
Case HitTestResult.OnItemIndent: s := "OnItemIndent";
Case HitTestResult.OnItemButton: s := "OnItemButton";
Case HitTestResult.OnItemRight: s := "OnItemRight";
Case HitTestResult.OnItemStateIcon: s := "OnItemStateIcon";
Case HitTestResult.Above: s := "Above";
Case HitTestResult.Below: s := "Below";
Case HitTestResult.ToLeft: s := "ToLeft";
Case HitTestResult.ToRight: s := "ToRight";
End Select;
If Node <> Null Then
s := Node.Text + '(' + s + ')';
End If;
Self.Text := s;
End Sub TreeList1OnMouseDown;
On clicking the TreeList1 component area, it is checked if this area contains some element. The component area and element text if it is in this area are displayed in the form title.
See also: