Hi,
I'm not sure if that's possible using a built-in solution but you could just create a tight coupling between the two forms and when
the parent form is activated, check a variable to see if the child form is visible and if so activate the child form.
.... Out of curiosity I just tested my suggestion and it worked as expected, however the ParentForm appears and behaves a bit strange
while the DialogForm is shown. For one thing the XP hover styles of buttons, for instance, are active. Another thing is that the
border chrome is always in the inactive state but you can move the Form. Might need some elbow grease for that one but I can't
imagine that being a big issue.
The minimize, maximize, close and system buttons are all unclickable, which is desired. Also, you can't activate any controls or
click buttons while the DialogForm is visible, which is the point, of course. Here's the partial code:
class ParentForm : Form
{
private readonly DialogForm dialogForm;
public ParentForm()
{
InitializeComponent();
dialogForm = new DialogForm();
dialogForm.Owner = this;
}
private void btnShowDialog_Click(object sender, EventArgs e)
{
dialogForm.Show();
}
protected override void OnActivated(EventArgs e)
{
if (dialogForm.Visible)
{
SystemSounds.Beep.Play(); // lol
dialogForm.Activate();
}
base.OnActivated(e);
}
protected override void OnClosed(EventArgs e)
{
dialogForm.Dispose();
base.OnClose(e);
}
}