LineShape.HitTest Method

Gets information about the LineShape control at the specified point on the screen.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)


Public Overrides Function HitTest ( _
    x As Integer, _
    y As Integer _
) As Boolean
Dim instance As LineShape 
Dim x As Integer 
Dim y As Integer 
Dim returnValue As Boolean 

returnValue = instance.HitTest(x, y)
public override bool HitTest(
    int x,
    int y
virtual bool HitTest(
    int x, 
    int y
) override
public override function HitTest(
    x : int, 
    y : int
) : boolean


Return Value

Type: System.Boolean
true if the LineShape control is located at the specified coordinates; otherwise false.


The X and Y parameters represent the current mouse coordinates relative to the screen, not to the LineShape control container.


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 Sub LineHitTestForm_PreviewKeyDown(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) _
 Handles Me.PreviewKeyDown
    If e.KeyCode = Keys.Space Then 
        Dim px As Integer 
        Dim py As Integer 
        Dim hit As Boolean
        px = LineHitTestForm.MousePosition.X
        py = LineHitTestForm.MousePosition.Y
        hit = LineShape1.HitTest(px, py)
    End If 
End Sub
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();

.NET Framework Security

See Also


LineShape Class

LineShape Members

Microsoft.VisualBasic.PowerPacks Namespace



Other Resources

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)