This documentation is archived and is not being maintained.

AccessibleObject.HitTest Method

Retrieves the child object at the specified screen coordinates.

[Visual Basic]
Public Overridable Function HitTest( _
   ByVal x As Integer, _
   ByVal y As Integer _
) As AccessibleObject
public virtual AccessibleObject HitTest(
 int x,
 int y
public: virtual AccessibleObject* HitTest(
 int x,
 int y
public function HitTest(
   x : int,
 y : int
) : AccessibleObject;


The horizontal screen coordinate.
The vertical screen coordinate.

Return Value

An AccessibleObject that represents the child object at the given screen coordinates. This method returns the calling object if the object itself is at the location specified. Returns a null reference (Nothing in Visual Basic) if no object is at the tested location.


Exception Type Condition
COMException The control cannot be hit tested.


For nonrectangular objects such as list view items, the coordinates of the object's bounding rectangle retrieved by Bounds can fail if tested with HitTest, because HitTest determines the object's boundaries on a pixel-by-pixel basis.

Notes to Inheritors:  All visual objects must support this method; sound objects do not support it.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

AccessibleObject Class | AccessibleObject Members | System.Windows.Forms Namespace