This example uses the Arrange method to arrange windows and icons in an MDI form. To try this example, paste the code into the Declarations section of an MDI form named MDIForm1 that has an MDI child form (named Form1, with its MDIChild property set to True) and a picture box on the MDI Form (named Picture1). Press F5 and click anywhere in the picture box to see the effects of the Arrange method.
Const FORMCOUNT = 5
Dim F(1 To FORMCOUNT) As New Form1
Private Sub MDIForm_Load ()
Dim I ' Declare local variable.
Load Form1 ' Load original Form1.
For I = 1 To FORMCOUNT
F(I).Caption = "Form" & I + 1 ' Change caption on copies.
Next I
End Sub
Private Sub Picture1_Click ()
Static ClickCount ' Declare variables.
Dim I, PrevWidth, Start
ClickCount = ClickCount + 1 ' Increment click counter.
Select Case ClickCount
Case 1
MDIForm1.Arrange 1 ' Tile horizontally.
Case 2
MDIForm1.Arrange 2 ' Tile vertically.
Case 3 ' Minimize each form.
PrevWidth = MDIForm1.Width ' Get MDI form width.
MDIForm1.Width = PrevWidth / 2 ' Divide it in half.
Form1.WindowState = 1 ' Minimize the original.
For I = 1 To FORMCOUNT ' Look at each instance of F.
F(I).WindowState = 1 ' Minimize each copy of F.
Next I
Start = Timer
Do
Loop Until Timer = Start + 5
MDIForm1.Width = PrevWidth ' Resize to original size.
MDIForm1.Arrange 3 ' Arrange icons.
End Select
End Sub