Login form not losing focus correctly
I have a system in which the main form is the menu, and it pops up a login form on loading. 
Originally it loaded the login form below the menu, so I used this.topmost = true to make it come to the front. (as bring to front and send to back did not work) 

However, if the user then clicks on something else, say chrome, then it still stays at the top of the z-order, by definition of topmost.

I tried to use the deactivate event, but this meant that on load it once again comes up behind the menu form. 

How could I stop it from loading behind my menu form, and yet when it loses focus stop it from being topmost?



private void login_Deactivate(object sender, EventArgs e)

        {
            // do not want it to remain top most when the application is not in focus.
            this.TopMost = false;
        }


In the Menu form:

 private void Menu_Load(object sender, EventArgs e)
        {
             openLogin()
        }

private void openLogin()

        {
            Cursor.Current = Cursors.WaitCursor;
            login theForm = new login(this);            
            this.Enabled = false;            
            theForm.Show();
            Cursor.Current = Cursors.Default;
            theForm.Activate(); 
            theForm.TopMost = true; // Make the login form display over the Menu                       
        }


Login form not losing focus correctly
===

I have a system in which the main form is the menu, and it pops up a login form on loading. 
Originally it loaded the login form below the menu, so I used this.topmost = true to make it come to the front. (as bring to front and send to back did not work) 

However, if the user then clicks on something else, say chrome, then it still stays at the top of the z-order, by definition of topmost.

I tried to use the deactivate event, but this meant that on load it once again comes up behind the menu form. 

How could I stop it from loading behind my menu form, and yet when it loses focus stop it from being topmost?



private void login_Deactivate(object sender, EventArgs e)

        {
            // do not want it to remain top most when the application is not in focus.
            this.TopMost = false;
        }


In the Menu form:

 private void Menu_Load(object sender, EventArgs e)
        {
             openLogin()
        }

private void openLogin()

        {
            Cursor.Current = Cursors.WaitCursor;
            login theForm = new login(this);            
            this.Enabled = false;            
            theForm.Show();
            Cursor.Current = Cursors.Default;
            theForm.Activate(); 
            theForm.TopMost = true; // Make the login form display over the Menu                       
        }

