views:

706

answers:

5

I have a little log in screen that pops up if a user selects a certain item on my main form. How do I get my code to stop executing til my log in form closes?

This is what I am doing so far. Basically i want o execute the code after MyLogin closes.

    BMSSplash.MyLogin.Show()

    If isLoggedIn Then
        BMSSplash.MyBuddy.Show()
        Cursor.Current = Cursors.WaitCursor
    End If
+3  A: 

One easy and reasonable option would be to show the form modally with ShowDialog instead of Show. This will block the rest of your application until the form is closed:

If BMSSplash.MyLogin.ShowDialog() = DialogResult.OK Then
    ' Form was closed via OK button or similar, continue normally... '
    BMSSplash.MyBuddy.Show()
Else
    ' Form was aborted via Cancel, Close, or some other way; do something '
    ' else like quitting the application... '
End If
stakx
A: 

To stop other code from executing you need to show the other window as a modal dialog. This is typically done an WinForms type by calling the ShowDialog overload which accepts anIWin32Window` overload and passing the currently executing form. Typically Me.

BMSSplash.MyBuddy.ShowDialog(Me)

I don't have much experience with splash screen implementations though and it may have a slightly different API.

JaredPar
Oh no I just have my splash screen doing all the work up front.
Sean P
+1  A: 

Use BMSSplash.MyLogin.ShowDialog() instead to have the window shown as what is referred to as a modal dialog.

klausbyskov
A: 

p.s. If you want to do .showDialog with a "splash" screen, you can add a timer on that form and have it me.dispose when the timer fires.

tobrien
A: 

Thank you so much guyz!!!!!your code really helped me a lot. Thanks again and bye....

Mohammed Hameed