Chris's Event Programming with Visual Basic course.
Contents
| Introduction | Tool Bars & Control Arrays |
Multiple
Document Interface (MDI)
An MDI (Multiple-Document Interface) form is a window that acts as
the background of an application and is the container for forms that have
their MDIChild property set to True. You create an MDI form by choosing
New MDI Form from the File menu. An application can have only one MDI form
but many MDI child forms. If an MDI child form has menus, the child
form's menu bar automatically replaces the MDI form's menu bar when the
child form is active. A minimized MDI child form appears as an icon
within the MDI form. MDI forms can contain only menu and picture box controls
and custom controls that have an Align property. To place other controls
on an MDI form, you can draw a picture box on the form and then draw other
controls inside the picture box. You can use the Print method to
display text in a picture box on an MDI form, but you can't use this method
to display text on the MDI form itself. An MDI form cannot be modal.
Note that MDI child forms are designed independently of the MDI form,
but are always contained within the MDI form at run time.
Typically the interface for an application will contain Menus, toolbars, controls, prompts, message boxes and dialogues all of which will be associated with forms.
Open a new project and from the Window menu choose the Menu Design Option,
this opens the Menu Design Window. Complete the window as shown below,
then click on the Next Button.
Note that the & character in the Caption causes the Menu to display
the next character as underscored and enables the use of Alt & the
character as a mode of selection. Complete the next menu item details as
shown below, (the right arrow indents to the next level of menu selection)
Click on the OK button, the Form1 appears with a menu. Add a form to
the project and on this form build a menu as for form 1 but do not indent
the Minimise option, instead leave it at the same level as Form& Features.
Events can now be assigned to the Menu items.
Form2.Minimise can be coded to Minimise form2 as shown below:-
Sub min_Click ()
form2.WindowState = 1
End Sub
while Form1 (the start up form) can be made to show form2 when it is
similarly minimised:-
Sub min_Click ()
form2.Show
form1.WindowState = 1
End Sub
If this is ran you can see that each form has its own separately defined menu.
If it is desired, a customised tool bar could be incorporated.
Visual Basic and all other Microsoft products mentioned
in this series are trademarks of the Microsoft Corporation.