WinForms: finding the size of a minimized form without going to FormWindowState.Normal

Posted by Doc Brown on Stack Overflow See other posts from Stack Overflow or by Doc Brown
Published on 2010-05-20T17:24:58Z Indexed on 2010/05/20 17:40 UTC
Read the original article Hit count: 429

Filed under:
|
|

Is there an easy way to determine the size of a Form it does have in WindowState=Normal, without actually changing the Form state?

Here is what I do now (C# code):

public class MyForm: Form
{
     public void MyMethod()
     {
          // ...
          FormWindowState oldState = this.WindowState;
          this.WindowState = FormWindowState.Normal;

          Point windowLocation = this.Location;
          Size windowSize = this.Size;

          this.WindowState = oldState;
          //  ...
     }
}

This is what I would like the code to look like:

public class MyForm: Form
{
     public void MyMethod()
     {
          // no state change here
          Point windowLocation = this.NormalStateLocation;
          Size windowSize = this.NormalStateSize;
     }
}

In fact there are no NormalStateLocation or NormalStateSize properties in Windows Forms.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about winforms