Event when a window gets maximized/un-maximized

Suprising that no one mentioned the inbuilt .NET method.

This way you don’t need to override the Window Message Processing handler.

It even captures maximize/restore events caused by double-clicking the window titlebar, which the WndProc method does not.

Copy this in and link it to the “Resize” event handler on the form.

    FormWindowState LastWindowState = FormWindowState.Minimized;
    private void Form1_Resize(object sender, EventArgs e) {

        // When window state changes
        if (WindowState != LastWindowState) {
            LastWindowState = WindowState;


            if (WindowState == FormWindowState.Maximized) {

                // Maximized!
            }
            if (WindowState == FormWindowState.Normal) {

                // Restored!
            }
        }

    }

Leave a Comment