home *** CD-ROM | disk | FTP | other *** search
- Microsoft Foundation Classes Microsoft Corporation
- Technical Notes
-
- #5 : Multiple Document Interface (MDI) and Foundation
-
- This note describes the Foundation routines for supporting the
- Multiple Document Interface (MDI) of MS-Windows.
-
- -----------------------------------------------------------------------------
- The Problem
- ===========
-
- Creating a MDI frame window traditionally requires quite a bit of
- "boiler-plate" code. In order to simplify writing an MDI
- application, the Foundation class library provides as much of this
- boiler-plate code as possible. Because of this, the steps required
- to create an MDI frame window are different than in traditional
- MS-Windows programming.
-
- -----------------------------------------------------------------------------
- Creating a MDI Frame Window
- ===========================
-
- 1. Define a new class derived from CMDIFrameWnd
- 2. In the derived class constructor, invoke (for example):
-
- Create(NULL, pTitle, WS_OVERLAPPEDWINDOW, rectDefault, NULL, pMenuName);
-
- Notes:
- See MFC sample programs (sample\minmdi, sample\mdi, sample\multi) for
- complete, working examples of how to call CMDIFrameWnd::Create.
-
- The MDICLIENT window (the area where MDI children appear) is created
- by CMDIFrameWnd::CreateClient which is called from the default
- WM_CREATE handler for CMDIFrameWnd.
-
- When a MDICLIENT window is created it must be told which menu should
- contain the list of open MDI child windows and where the range of IDs
- for MDI child windows starts.
-
- CMDIFrameWnd::OnCreate assumes the Window menu is the second from
- the right end of the menu bar (in conformance with the User Interface
- Style Guide) and that MDI child window IDs should start at
- AFX_IDM_FIRST_MDICHILD (which is defined to be 0xff00; Windows and
- Foundation reserve IDs between 0xf000 and 0xffff for system use).
-
- If the default menu position is not satisfactory, OnCreate should be
- overridden and CreateClient called appropriately.
-
-
- -----------------------------------------------------------------------------
- Creating a MDI Child Window
- ===========================
-
- 1. Define a new class derived from CMDIFrameWnd
- 2. In the derived class constructor, invoke (for example):
-
- Create(NULL, pTitle, 0, rectDefault, pMDIFrameWnd)
-
- As above, see the MDI sample applications for complete examples.
-
- -----------------------------------------------------------------------------
- Command Accelerators
- ====================
-
- The default PreTranslateMessage functions handle manually loaded
- accelerator tables for both MDI child windows and the MDI frame as
- well as the standard MDI system-command accelerators normally handled
- by TranslateMDISysAccel.
-
- If the active MDI child window has an accelerator table attached to
- it, that table is searched first for keys as they are pressed. If a
- key is not found in the child's table, the MDI frame window is
- checked. If the key is not found in the frame's table either or the
- frame does not have a table, the key is passed to TranslateMDISysAccel.
- If that function translates the key, processing of the key stops.
- Otherwise, the key is sent to the window with the focus via one of
- OnKeyDown, OnSysKeyDown, OnChar, or OnSysChar.
-
- -----------------------------------------------------------------------------
- Other Functions
- ===============
-
- MDI Frame Windows
- -----------------
-
- GetChildFrame -- returns the active MDI child window or
- 'this' if there are no children.
- GetParentFrame -- returns 'this'.
- MDIActivate -- activates a particular MDI child.
- MDICascade -- arranges the MDI children so they overlap.
- MDIGetActive -- returns the active MDI child window or
- NULL if there are no children.
- MDIIconArrange -- arranges the MDI child icons.
- MDIMaximize -- maximizes a particular MDI child window.
- MDINext -- activate a different MDI child window.
- MDIRestore -- restores a particular MDI child window.
- MDISetMenu -- change the menu bar.
- MDITile -- arranges the MDI children to they don't overlap.
-
-
- MDI Child Windows
- -----------------
-
- GetChildFrame -- returns 'this'.
- GetParentFrame -- returns the parent MDI frame window.
- MDIDestroy -- destroys this MDI child window.
- MDIActivate -- activates this MDI child window.
- MDIMaximize -- maximizes this MDI child window.
- MDIRestore -- restores this MDI child window.
-