Apparently LoginForm
is a form that creates and shows your ChildForm
. While ChildForm is shown, LoginForm is not visible, nor can it have the focus. As soon as ChildForm is closed, LoginForm should become visible again and have the focus.
This looks like standard Modal Dialog behaviour to me, except the invisiblity.
class LoginForm : Form
{
private void ShowChild()
{
using (var childForm = new ChildForm(...))
{
// if needed: set ChildForm properties
...
// just before showing the childForm, hide this loginForm
this.Visible = false;
// show the childForm until it is closed
DialogResult dlgResult = childForm.ShowDialog(this);
// interpret the results of the childForm,
// for instance something like this:
switch (dlgResult)
{
// operator pressed OK; process the result and show the login
case DialogResult.OK:
string savedFileName = childForm.FileName;
this.Process(savedFileName);
break;
// operator indicates that program can close
case DialogResult.Cancel:
this.Close();
break;
// all other solutions: do nothing but show the login screen
default:
break;
}
// show the login screen
this.Visible = true;
}
}
}