HitTest(Pt: IPoint; Var Hit: HitTestResult): Integer;
Pt. The point, at which component element can 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 (only element icon and text are taken into account in any column), the method returns index of this element, otherwise the method returns -1. 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 DimensionCombo component that inherits from the IDimensionViewer interface.
Executing the example requires a form, the DimensionTree component named DimensionTree1 on the form and a data source for DimensionTree1. The specified procedure is set as the OnMouseDown event handler of the DimensionTree1 component.
Sub DimensionTree1OnMouseDown(Sender: Object; Args: IMouseClickEventArgs);
Var
DimInst: IDimInstance;
Node: Integer;
Result: HitTestResult;
s: String;
Begin
Node := DimensionTree1.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 > -1 Then
DimInst := DimensionTree1.Dimension.DimInstance;
s := DimInst.Elements.Name(Node) + '(' + s + ')';
End If;
Self.Text := s;
End Sub DimensionTree1OnMouseDown;
On clicking the DimensionTree1 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: