George Shepherd's Windows Forms FAQ
Questions and answers in this FAQ have been collected from newsgroup posts, various mailing lists and the employees of Syncfusion.

41. GDI+ Hit Testing

WinForms FAQ Home
   41.1 How to HitTest a polygonal region?



41.1 How to HitTest a polygonal region?


Bool HitTest(PointF[] polygonCorners, PointF mousePosition)
{
     GraphicsPath path = new GraphicsPath();
     path.AddLines(polygonCorners);
     Region region = new Region(path);

// Hittest the region to verify if the point is in the rect
     if(region.IsVisible(mousePosition))
          return true;
     else
          return false;
}

© 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap