What I implement
- My application hold mdi child forms(don't close) when user opens other child to keep last input data.
- Child forms are shown as Maximized.
What I want to stop
- When user input arrow keys after over two child forms were opened(I think it's when child form focused), child forms are navigated(Up/Left : prev child open, Down/Right : next child) and shown as Maximized property is released(some case didn't).
I have searched for long time, there are some solutions about capturing keys but any solutions for stop this.
Please help me.
+ conditions to reproduce this problem
- MDI parent has ToolStripPanel & ToolStrip docking at the right
- parent also have MenuStrip(Visible property set to false) docking at the top to hide child form's control box
- ToolStripButton's Click Event Handler show child form using spaghetti function like next
private void tsbChildForm1_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
if (m_frmChild != null)
{
if (typeof(Form1) != this.ActiveMdiChild.GetType())
{
m_frmChild = new Form1();
OpenChildForm(m_frmChild);
}
else
{
// do nothing. prevent memory increase
}
}
else
{
m_frmChild = new Form1();
OpenChildForm(m_frmChild);
}
}
private void OpenChildForm(Form frmChild)
{
if (LoadExistForm(frmChild))
{
// do nothing.
}
else
{
frmChild.MdiParent = this;
frmChild.WindowState = FormWindowState.Maximized;
frmChild.Show();
}
}
private bool LoadExistForm(Form frmChild)
{
foreach (Form frmEach in this.MdiChildren)
{
if (frmEach.Name.Equals(frmChild.Name, StringComparison.OrdinalIgnoreCase))
{
frmEach.Select();
frmEach.WindowState = FormWindowState.Maximized;
frmChild.Dispose();
return true;
}
}
return false;
}