Detecting clicks within a polygon

G

Guest

I am drawing a set of polygons, currently using graphics.DrawPolygon(...
What i want to do, is when the user clicks in the area of a polygon, to be
able to work out which polygon they have clicked in.
Could anyone suggest the easiest way of doing this, even if i have to change
the way i'm drawing the polygons?
 
M

Mattias Sjögren

What i want to do, is when the user clicks in the area of a polygon, to be
able to work out which polygon they have clicked in.
Could anyone suggest the easiest way of doing this, even if i have to change
the way i'm drawing the polygons?

You could create a GraphicsPath from the polygon points and then call
its IsVisible method.

Or you could use an algorith specifically for this. See Q 2.03 at
http://www.faqs.org/faqs/graphics/algorithms-faq/



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top