Search code examples
c#winformsmdimdichild

MDIchild windows, not stacking more than the center of the screen. A known limit?


This is simply an annoyance.
But the system seems to stack child windows properly for a while, but then at some point, before you expect it to, it begins re-stacking them over the top of the ones you've already laid.

Are there any configurations I can set? I mean for the size of the MDI setup that I'm missing. It seems to stop before the center of the screen. I will post a picture of a test project, but it is a little similar to what happens in the real project. I realize that I can do a 'Cascade' and other functions, to windows after they already in place. But that is not desirable. I also realize that MDI forms fell out of fashion a while back. Well... I'm not getting rid of them yet.enter image description here


Solution

  • I think this is what Hans was saying: In the test project I put this, and it works... Note: This is in the load of the MDIChild.

        private void Form2_Load(object sender, EventArgs e)
        {
            int t = 1, l = 1;
            int d = this.MdiParent.MdiChildren.GetUpperBound(0) - 1;
            if (d >= 0)
            {
                Form f = this.MdiParent.MdiChildren[d];
                t = f.Top + 20;
                l = f.Left + 20;
            }
    
            this.Top = t;
            this.Left = l;
        }