Showing posts with label Panel. Show all posts
Showing posts with label Panel. Show all posts

Thursday, May 28, 2009

Panel Hit Test in C# winforms

Today i wanted to check whether user click in with in the context of the panel. Since panel doesnt provide hittest this is how to do it ..

private bool panel_hit_test(Panel panel, POINT point_test)
{

Rectangle rect = panel.RectangleToScreen(panel.ClientRectangle);


if ((point_test.x > rect.X && point_test.x < rect.X + rect.Width) &&
(point_test.y > rect.Y && point_test.y < rect.Y + rect.Height))
{
return true;
}
else
return false;
}