在MDI上安排最小化的子窗口

时间:2015-09-03 08:22:41

标签: c# winforms mdi

我有一个带有多个子窗口的MDI程序。有什么方法可以影响或修改LayoutMdi( MdiLayout.ArrangeIcons)在表单中排列最小化子窗口的方式,或者有什么方法可以改变最小化子窗口的位置和/或大小(例如,在同一种类型的窗口中)我可以使用SetBounds

来改变未经校正的子窗口的位置和大小

1 个答案:

答案 0 :(得分:1)

来自:https://social.msdn.microsoft.com/Forums/windows/en-US/d6014e48-2adb-4096-8bea-94c2f3b1c47c/how-to-change-the-location-of-a-minimized-mdichild-form?forum=winforms

    [DllImport("user32.dll")]
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

    public FormA() {
        Button btn = new Button { Text = "asdf" };
        Controls.Add(btn);
        IsMdiContainer = true;
        var f1 = new Form { Text = "Form1", TopLevel = false, MdiParent = this};
        var f2 = new Form { Text = "Form2", TopLevel = false, MdiParent = this};
        var f3 = new Form { Text = "Form3", TopLevel = false, MdiParent = this};
        f1.Show();
        f2.Show();
        f3.Show();
        btn.Click += delegate {
            //this.LayoutMdi(MdiLayout.ArrangeIcons);
            //f1.Bounds = new Rectangle(50, 50, 100, 30);
             int top = 100;
             SetWindowPos(f1.Handle, IntPtr.Zero, f1.Left, top, f1.Width, f1.Height, 0);
        };
   }