I have an application which uses a main window. But before showing the
Main Window (which is best done by Application.Run(new MainWindow();) I
need to show a Login Window. When the login fails, the application
should terminate but when the login is successful the loginwindow should
be destroyed and the main application window should be presented to the
user.
What is the best way to do it?
-Can I call loginwindow.Showdialog() before calling Application.Run(new
MainWindow()
-Or should I create and show the loginwindow, then call
Application.Run() without a form as parameter and within the loginwindow
either call application.exit() or instantiate the MainWindow and upon
closing the mainwindow call application.exit().
Regards
Stephan
Kevin Spencer - 30 Nov 2006 16:08 GMT
The easiest way is to call the loginWindow.ShowDialog() method in the OnLoad
method of your form. The form will not appear until the OnLoad method
completes, and it can check the DialogResult of the method execution to
determine whether or not to close.

Signature
HTH,
Kevin Spencer
Microsoft MVP
Logostician
http://unclechutney.blogspot.com
Parabola is a mate of plane.
>I have an application which uses a main window. But before showing the Main
>Window (which is best done by Application.Run(new MainWindow();) I need to
[quoted text clipped - 11 lines]
> Regards
> Stephan