How to get the size of unlimited size of the form?

I am trying to maintain a state System::Windows::Forms::Formwhen my application shuts down. I can record the state of the window, the position and state of the window without any problems, but if the window was maximized when it was closed, the member ::Sizerecords the maximum size of the window.

Is there a way to record a non-maximized size, or do I need to intercept the on-maximize event and record it manually?

+3
source share
1 answer

It is not always available, you will have to P / Invoke GetWindowPlacement. The best approach is to record only the size of the window if the form is in the correct state. For instance:

    protected override void OnResize(EventArgs e) {
        if (this.WindowState == FormWindowState.Normal)
            Properties.Settings.Default.WindowSize = this.Size;
        base.OnResize(e);
    }
+2
source

Source: https://habr.com/ru/post/1751403/


All Articles