locked
changing the default border style of mdi child forms RRS feed

  • Question

  • Is there any way to change the way a container form displays a mdi child form?  In particular I want to eliminate the 3D sunken look that the child form takes on when it is maximized.  I would like the parent and child to be seemless when maximized.
    Saturday, July 9, 2005 3:14 AM

Answers

  • 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.


    Wednesday, July 13, 2005 3:06 AM

All replies

  • Hi,

    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
    Saturday, July 9, 2005 5:40 AM
  • The only problem with this solution is when maximized the windows bar of the child is still visible - it just appears like a main windows form running inside another.  I would still rather run this as a MDI app with the MDI form not taking the default sunken 3D appearance.
    Sunday, July 10, 2005 6:21 AM
  • 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.


    Wednesday, July 13, 2005 3:06 AM