5. Multiple document
Interface:
The MDI was
designed to simplify the exchange of information among documents, all under the
same roof. With a MDI application, you
can maintain multiple windows, but not multiple copies of the application. Data exchange is easier when you can view
and compare many documents simultaneously.
The main form or MDI form is not duplicated, but it acts as a container
for all the windows, and it is called the parent window.
A MDI
application must have at least two forms, the parent form and one or more child
forms. There can be many child forms,
but only one parent form. He parent
form may not contain controls. While
the parent form is open in the design mode, though the icons in the toolbox are
not disabled, but you cannot place any control on the form. But you can place controls in child forms.
To create a MDI application follow these steps:
1.
Start
a new project, and choose Project>Add MDI form to add the form
2.
Set
the form’s caption to
MDIwindow.
3.
Choose
Project>Add form to add a regular form.
4.
Make
this form child by setting its MDIChild property true. To denote that this is a child form set its
caption to MDIChild.
5.
Double-click
your picture control in the tool box.
It will appear as toolbar to your MDI form.
6.
Place
three command buttons on this toolbar and change their names and captions to
newchild, cascade and tile respectively.
7.
The
MDI window will look as in the figure 9.
8.
Enter
the codes as shown in the figure 9a.
9.
Save
and run the project.
10.
See
how you can arrange the child windows in tiles or cascades. You cannadd any number of child windows by
clicking the newchild button. A
typical tile arrangement of child windows is shown in the figure 10 and cascade
arrangement of the child windows in the figure 11.
Dim
i
Private
Sub
cascade_Click()
MDIForm1.Arrange
0
End
Sub
Private
Sub
newchild_Click()
Dim
obj As Form1
Set
obj = New Form1
obj.Caption
= obj.Caption & i
obj.Show
i =
i + 1
End
Sub
Private
Sub
MDIForm_Load()
i =
2
End
Sub
Private
Sub
tile_Click()
MDIForm1.Arrange
1
End
Sub
Figure 9a

Figure 9

Figure 10

Figure
11
   |