C# How to check if form is not visible (minimized) : Sorry for my bad english.

I am using this code to check if the form is minimized:

            [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_SYSCOMMAND:
                    int command = m.WParam.ToInt32() & 0xfff0;
                    if (command == SC_MINIMIZE)
                    {
                        MessageBox.Show("Minimized");
                        Variaveis.telaMinimizada = true;
                    }
                    else
                    {
                        Variaveis.telaMinimizada = false;
                        MessageBox.Show("Maximized");
                    }

                    break;
            }
            base.WndProc(ref m);
        }

This code works like a charm. When i click on minimize button, appear the message "minimized", and when i reopen the application, appear the message "maximized"

But there is a problem. **Not always people minimize the form by clicking on minimize button.** I mean, **if i click on screen OUT the form**, the form will also minimize, and when this happen, the code i have do not detect that the form got minimized.

How can i check if the form is minimized (or is invisible on screen) when the form get minimized after clicking **OUT** the form?

Ideas? Thanks!