Windowing Applications

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

  1. Start a new Standard EXE project in Visual Basic.
  2. Rename Form1 to frmChild .
  3. Set frmChild's MDIChild property to True .
  4. Add an MDI form to the application.
  5. Resize the MDI form to accommodate child windows .
  6. Set the following properties on the MDI form:
    Property Setting
    Name mdiMain
    Caption MDI Main Form
    StartUpPosition 2-CenterScreen

  7. Under Project Properties, set mdiMain as the Startup Object.
  8. 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

  9. 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 

  10. Add the appropriate code to exit from the application in the mnuExit_Click event.
* To display a bitmap to the user
  1. Add a picture box and a command button to frmChild .
  2. Set the control's properties as follows :
    Control Property Setting
    Picture Box Name PicMain
    Command Button Name CmdLoad
      Caption Load Picture

  3. Add the following code to cmdLoad's Click event:
     Set picMain.Picture = LoadPicture("c:\program files" & _ "\devstudio\vb\graphics\metafile\arrowsdarrow1.wmf") 
  4. 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.

click to view at full size.

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.

click to view at full size.

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.


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net