Building a Multiple Document Interface
In this exercise, you will create an MDI application that will display a bitmap to the user .
* To create an MDI application
- Start a new Standard EXE project in Visual Basic.
- Rename Form1 to frmChild .
- Set frmChild's MDIChild property to True .
- Add an MDI form to the application.
- Resize the MDI form to accommodate child windows .
- Set the following properties on the MDI form:
Property | Setting |
Name | mdiMain |
Caption | MDI Main Form |
StartUpPosition | 2-CenterScreen |
- Under Project Properties, set mdiMain as the Startup Object.
- Create a menu for mdiMain. New Child and Exit are menu items under File . Use the following properties:
Menu | Property | Setting |
File | Name | mnuFile |
| Caption | &File |
New Child | Name | mnuNewChild |
| Caption | &New Child Window |
Exit | Name | mnuExit |
| Caption | E&xit |
Window | Name | mnuWindow |
| Caption | &Windows |
| WindowList | Checked |
- Add the following code mnuNewChild's click event:
Dim newchild As Form Static child_num As Integer child_num = child_num + 1 Set newchild = New frmChild newchild.Caption = "Child Form #" & child_num newchild.Visible = True
- Add the appropriate code to exit from the application in the mnuExit_Click event.
* To display a bitmap to the user - Add a picture box and a command button to frmChild .
- Set the control's properties as follows :
Control | Property | Setting |
Picture Box | Name | PicMain |
Command Button | Name | CmdLoad |
| Caption | Load Picture |
- Add the following code to cmdLoad's Click event:
Set picMain.Picture = LoadPicture("c:\program files" & _ "\devstudio\vb\graphics\metafile\arrowsdarrow1.wmf")
- Save and test your work.
Single Document Interface
An example of the SDI interface is the Microsoft WordPad application that is included with Microsoft Windows. In Microsoft WordPad, only a single document can be open; you have to close one document in order to open another.
Figure 12.11 Single document interface The SDI style is the most common interface style used in applications; most of the examples in the Programmer's Guide assume an SDI application.
Windows Explorer Interface
In addition to the two most common interface styles, SDI and MDI, the Windows Explorer-style interface is popular. The Windows Explorer interface is a single window containing two panes or regions , usually consisting of a tree or hierarchical view on the left and a display area on the right. This type of interface lends itself to navigating or browsing large numbers of documents, pictures, or files.
Figure 12.12 The Windows Explorer interface Lesson Summary
Windows provides three types of interfaces: multiple document interfaces (MDI), single document interfaces (SDI), and the Windows Explorer interface. MDI interfaces allow you to display multiple documents at the same time, with each document displayed in its own window. Microsoft Excel and Word for Windows have MDI interfaces. SDI applications have only one interface and do not contain any child windows. Microsoft WordPad is an example of a single document interface. The Windows Explorer interface is useful for navigating large numbers of documents or files. It displays a tree view of the information on the left of its window, and provides a display area on the right.