How to detect when a windows form is being minimized?

c#, winforms

Solution

You can use the Resize event and check the Forms.WindowState Property in the event.

private void Form1_Resize ( object sender , EventArgs e )
{
    if ( WindowState == FormWindowState.Minimized )
    {
        // Do some stuff
    }
}

Problem

I know that I can get the current state by WindowState, but I want to know if there's any event that will fire up when the user tries to minimize the form.

Original source

Related problems