Shape.HitTest Method
Gets information about a line or shape control at the specified position on the screen.
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Parameters
- x
- Type: System.Int32
The horizontal screen coordinate.
- y
- Type: System.Int32
The vertical screen coordinate.
Return Value
Type: System.Booleantrue if the line or shape control is located at the specified coordinates; otherwise, false.
The following example demonstrates how to use the HitTest method of the LineShape control to determine whether the pointer is positioned over the control when the SPACEBAR is pressed.
private void LineHitTestForm_PreviewKeyDown(object sender, System.Windows.Forms.PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Space) { int px; int py; bool hit; string result; px = LineHitTestForm.MousePosition.X; py = LineHitTestForm.MousePosition.Y; hit = lineShape1.HitTest(px, py); result = hit.ToString(); MessageBox.Show(result); } }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.