Event when a window gets maximized/un-maximized

前端 未结 10 874
失恋的感觉
失恋的感觉 2020-11-27 05:48

Is there an event that is fired when you maximize a Form or un-maximize it?

Before you say Resize or SizeChanged: Those get only fired if t

10条回答
  •  余生分开走
    2020-11-27 06:16

    Another little addition in order to check for the restore to the original dimension and position after the maximization:

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
    
        // WM_SYSCOMMAND
        if (m.Msg == 0x0112)
        {
            if (m.WParam == new IntPtr(0xF030) // Maximize event - SC_MAXIMIZE from Winuser.h
                || m.WParam == new IntPtr(0xF120)) // Restore event - SC_RESTORE from Winuser.h
            {
                UpdateYourUI();
            }
        }
    }
    

    Hope this help.

提交回复
热议问题