Firstly, I'm guessing you've set your login form as the application's startup form? If so then VB has put something like this together for you behind the scenes:
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New LoginForm)
The magic happens there in that Application.Run
call, which basically creates a message loop for your GUI and terminates when it detects that your form has been closed.
There are a couple of ways that I know of to deal with this.
- First: don't make the login form your startup form at all. Create your main form, but cause it to hide itself and
ShowDialog
on an instance of your login form before appearing.
- Make your login form your startup object, but instead of closing it when you open your main form, simply hide it (this is actually pretty horrendous to me personally, but it's a possibility).
As for the MDI form question: this seems completely possible to me, if I understand you correctly. You want to show both the login form and the MDI form at once, but you want the MDI form to be disabled until the login form is closed, right?
So just make the MDI form your application's startup form, have it call ShowDialog
on your login form in its Load
event, and bingo: the MDI form will effectively be "locked" until the login form is dealt with (this is how modal dialogs in general such as MessageBox
work). This is actually the same as option #1 above except that the main form (your MDI form) is never hidden, only blocked.