AccessibleObject.HitTest(Int32, Int32) Method

Definition

检索位于指定屏幕坐标的子对象。Retrieves the child object at the specified screen coordinates.

public:
 virtual System::Windows::Forms::AccessibleObject ^ HitTest(int x, int y);
public virtual System.Windows.Forms.AccessibleObject HitTest (int x, int y);
abstract member HitTest : int * int -> System.Windows.Forms.AccessibleObject
override this.HitTest : int * int -> System.Windows.Forms.AccessibleObject
Public Overridable Function HitTest (x As Integer, y As Integer) As AccessibleObject

Parameters

x
Int32

水平屏幕坐标。The horizontal screen coordinate.

y
Int32

垂直屏幕坐标。The vertical screen coordinate.

Returns

AccessibleObject

一个 AccessibleObject,表示位于给定屏幕坐标位置的子对象。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. 如果测试位置没有对象,则返回 nullReturns null if no object is at the tested location.

Exceptions

无法对控件进行点击检测。The control cannot be hit tested.

Remarks

对于不包含列表视图项的非矩形对象,如果使用 HitTest进行测试,则 Bounds 检索的对象的边框坐标可能会失败,因为 HitTest 按像素的方式确定对象的边界。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.

Applies to