How to create a log in window?

  • Thread starter Thread starter Andy Pollak
  • Start date Start date
A

Andy Pollak

Hi!

I want to create a small log in window for my application,
the same way Windows 2000 or similar programs do. It
should show immediately after the main form has been
loaded and displayed, i.e. the main form and the (modal)
log in form should be visible at the same time.

The problem is: How and where can I load the (modal) log
in form?

Using the Activated, Load, and Enter events of the main
form did not help, because the are called before (!) the
main form is displayed on the screen. Overriding WndProc
to catch the WM_SHOWWINDOW message produced the same
result.

Any idea would be greatly appreciated.

Many thanks in advance!

Best regards

Andy
 
An extension to that, which I use, is to make the
mainForm come up conditionally only if the login passes.
If they don't log in, the form never even gets
instantiated. It's nice to have that one windowless class
that starts up. Much more options.

<code>

protected frmMain m_mainForm;
[STAThread]
public static void Main()
{
frmLogin loginForm = new frmLogin();

// Do all your login processing in the login dialog
DialogResult dlgRes = frmLogin.ShowDialog();

if (dlgRes != DialogResult.OK)
return;

m_mainForm = new frmMain();
m_mainForm.Show();
}
 
Back
Top