21.1 Elements of a Multiple Document Interface Application

Like most Windows applications, an MDI application contains a message loop for dispatching messages to the application's various windows. The MDI message loop is similar to normal message loops, except for the way it handles menu accelerator keys.

The main window of an MDI application is similar to that of most Windows applications. In an MDI application, the main window is called the frame window and differs from a normal main window in that its client area is filled by a special child window called the client window. Because Windows maintains the MDI client window and controls the MDI interface, the application need not store a lot of information about the MDI user interface. (In this sense, the MDI client window is similar to a standard control, such as a radio button; it has a standard behavior that Windows provides automatically. The application can use the client window but need not provide code that defines how the window appears or behaves.)

Visually, an MDI client window is simply a large monochromatic rectangle. To the user, the client window is part of the main window; it provides a background upon which the child windows appear. The application defines the child windows; usually, there is one child window per document. The MDI child windows look much like the main window: They have window frames, System menus, and Minimize and Maximize buttons. The main difference to the user is that each child window contains a separate document. Also, the child windows cannot move outside the client window.

The following figure shows the sample application Multipad, a typical MDI application:

In general, an application controls the MDI interface by passing messages up and down the hierarchy of MDI windows. The MDI client window, which Windows controls, carries out many operations on behalf of the application.