Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I get the Form's ClientRectangle position in non-client coordinates?

I would like to use the Region property to create a form with hidden non-client areas (not exactly a rectangle), but I can't determine the client area rectangle position in non-client coordinates.

The code I usually use to get this offset is:

Point formClientScreenLocation = 
  parent.PointToScreen(
    new Point( parent.ClientRectangle.Left, parent.ClientRectangle.Top ) );
int x = formClientScreenLocation.X - parent.DesktopLocation.X + this.Location.X;
int y = formClientScreenLocation.Y - parent.DesktopLocation.Y + this.Location.Y;
region.Translate(x, y);



Page view counter