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

public Shape GetChildAtPoint(
    Point point
)
public:
Shape^ GetChildAtPoint(
    Point point
)
member GetChildAtPoint : 
        point:Point -> Shape
Public Function GetChildAtPoint (
    point As Point
) As Shape

Parameters

  • pt
    A Point that contains the coordinates of the location where you want to look for a shape. Coordinates are expressed relative to the upper-left corner of the screen.

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 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);
}
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

See Also

GetChildAtPoint Overload
ShapeContainer Class
Microsoft.VisualBasic.PowerPacks Namespace
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)

Return to top