开发者

How do I get the non-maximised window size of a form?

I'm trying to save my the state of a System::Windows::Forms::Form when my application shuts down. I can record the window's size, position and window stat开发者_开发问答e without any issues but if the window was maximised when it was closed the ::Size member records the maximised size of the window.

Is there any way to record the non-maximised size or do I need to intercept the on-maximise event and record it manually?


This is not readily available, you'd have to P/Invoke GetWindowPlacement. The best approach is to only record the window size if the form is in the proper state. For example:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜