Share via


ShapeContainer.GetChildAtPoint Method (Point)

Gets the shape that is located at the specified coordinates.

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

Syntax

'Declaration
Public Function GetChildAtPoint ( _
    point As Point _
) As Shape
public Shape GetChildAtPoint(
    Point point
)
public:
Shape^ GetChildAtPoint(
    Point point
)
member GetChildAtPoint : 
        point:Point -> Shape
public function GetChildAtPoint(
    point : Point
) : Shape

Parameters

  • point
    Type: Point

Return Value

Type: Microsoft.VisualBasic.PowerPacks.Shape
A Shape that represents the shape that is located at the specified point.

Remarks

If there is no shape at the specified point, the GetChildAtPoint method does nothing.

Note

The pt parameter returns a Point expressed in screen coordinates. This must be converted to client coordinates by using the PointToScreen method.

Examples

The following example demonstrates how to use the GetChildAtPoint method to return the shape located where the user clicks. This example requires that you have at least one RectangleShape control on a form.

Private Sub ShapeContainer1_MouseDown(
    ByVal sender As Object, 
    ByVal e As System.Windows.Forms.MouseEventArgs
  ) Handles ShapeContainer1.MouseDown

    Dim sh As Shape
    ' Find the shape at the point where the mouse was clicked.
    sh = ShapeContainer1.GetChildAtPoint(New Point(e.X, e.Y))
    MsgBox(sh.Name)
End Sub
private void shapeContainer1_MouseDown(object sender, 
    System.Windows.Forms.MouseEventArgs e)
{
    Shape sh;
    // Find the shape at the point where the mouse was clicked.
    sh = shapeContainer1.GetChildAtPoint(new Point(e.X, e.Y));
    MessageBox.Show(sh.Name);
}

.NET Framework Security

See Also

Reference

ShapeContainer Class

GetChildAtPoint Overload

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the Line and Shape Controls (Visual Studio)

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

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