Académique Documents
Professionnel Documents
Culture Documents
Start a new project and remove the existing Form1 (select Remove
Form1 from the Project menu).
Select Add MDI Form, New, from the Project menu. Click on MDI Form.
Click Open.
Change the Name property for this form to MDIEditor.
Adding the child form
Select Add Form, Existing, from the Project menu and add the form
you developed for the FileViewer application (frmFileViewer.frm).
Select the Fileviewer form. Change the MDIChild property to True.
Change the Name property to frmDoc. Save the form
as frmDoc.frm. Save the MDI form as mdiEditor.frm and the project
as MDI.vbp
You will write code to create a new instance of this form each time a new document
is opened.
Resizing the rich textbox
The child forms in an MDI application can be resized independently. The rich textbox
control should grow or shrink with the form. The resize event for the form can be
used to achieve this.
Add the following code to the Resize event for the frmDoc form
Private Sub Form_Resize()
rtbDisplay.Move 0,0,Me.Width 100, Me.Height - 300
End Sub
Setting up the menus
You have a choice of how you set up menus for an MDI project:
attach all the menu options to the MDI form and disable the options not
available until there is a child form open
attach menu options to the child form and use a different menu on the MDI
form the menu on the MDI form will automatically be replaced by the menu
on the child form as soon as a child form is opened
The child form that you have just added to the project, already has a menu attached
so the second option is preferable for this project.
The main MDI form can be given a simple menu to enable the first document to be
opened.
Select the MDIEditor form and use the Menu Editor to set up a menu
which looks like the following
Caption
Name
&File
mnuFile
&New
mnuNew
&Open
mnuOpen
mnuSep1
E&xit
mnuExit
Copy the code from the frmDoc form New and Open options to the
New and Open options for the MDIEditor form.