Don't work with MDI if you want seemless form display. Your parent form should be an ordinary form, and the childforms (the forms inside the parent form) must have this following property set:
TopLevel = false
Parent = The instance of the parent form.
Your code, should look like this (assuming you're creating instance of childform inside the parent form):
private void CreateChildForm()
{
ChildForm child = new ChildForm();
child.TopLevel = false;
child.Parent = this;
child.Show();
child.WindowState = FormWindowState.Maximized;
}
Best Regards,
- chris
Yes, when childform is maximized inside the parent mdi form; it is docked to fill the entire client-area, while the client are of the mdi-parent form has a default WS_EX_CLIENTEDGE (0x00000200) set-on. You can get rid of this defaults set by .NET, by overriding the CreateParams of the parent form when a child form is maximized, i.e.,:
protected override CreateParams CreateParams
{
get
{
int WS_EX_CLIENTEDGE = 0x00000200;
CreateParams cp = base.CreateParams;
if ( (cp.ExStyle & WS_EX_CLIENTEDGE) == WS_EX_CLIENTEDGE )
cp.ExStyle -= WS_EX_CLIENTEDGE;
return cp;
}
}
Documentations (MSDN) says, this should work into solving the problem of sunken style of client-area, however, it didn't. I hope, somebody can point any workaround :)
As for the previous method I described; that's the way I made seemless display working (back when I worked with docking windows for my UI), by removing the border of the child-form (docked window), and move it (docking) somewhere on the parent-form, with created fake title bars -- this way, I had no problems with auto-hide, and resize, and turn in back into a floating window.
- chris.