June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to detect if a user clicks inside a shape.
Test the point where the user clicked with the Rectangle.Contains or GraphicsPath.IsVisible method.
If you are creating a program that has custom graphical elements the user can interact with, you need to be able to determine when the user’s mouse is inside or outside a given shape. The .NET Framework provides two methods that can help with this task. The first is the Rectangle.Contains method, which takes a point and returns True if the point is inside the rectangle.
For example, you might add the following code to the drawing program demonstrated in recipe Paint Dynamic Content to check if the point where the user right-clicked lies inside ...
Read now
Unlock full access