2015-09-03 54 views
0

我有一個帶有多個子窗口的MDI程序。有沒有什麼方法可以影響或修改LayoutMdi(MdiLayout.ArrangeIcons)在表單中最小化子窗口的方式,或者有什麼方法可以改變最小化子窗口的位置和/或大小(例如,以我能夠以同樣的方式更改使用SetBounds)的unminimised子窗口安排MDI上的最小化子窗口

+0

你深深地潛入到一個狹窄的海。出來並重新思考你的業務邏輯的實現。 – Lali

+0

類似:http://stackoverflow.com/questions/4813637/is-it-possible-to-change-size-of-minimized-window-in-mdi-c-sharp-winforms – Loathing

回答

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); 
     }; 
    }