|
|
1.1 root 1: Microsoft Foundation Classes Microsoft Corporation
2: Technical Notes
3:
4: #5 : Multiple Document Interface (MDI) and Foundation
5:
6: This note describes the Foundation routines for supporting the
7: Multiple Document Interface (MDI) of MS-Windows.
8:
9: -----------------------------------------------------------------------------
10: The Problem
11: ===========
12:
13: Creating a MDI frame window traditionally requires quite a bit of
14: "boiler-plate" code. In order to simplify writing an MDI
15: application, the Foundation class library provides as much of this
16: boiler-plate code as possible. Because of this, the steps required
17: to create an MDI frame window are different than in traditional
18: MS-Windows programming.
19:
20: -----------------------------------------------------------------------------
21: Creating a MDI Frame Window
22: ===========================
23:
24: 1. Define a new class derived from CMDIFrameWnd
25: 2. In the derived class constructor, invoke (for example):
26:
27: Create(NULL, pTitle, WS_OVERLAPPEDWINDOW, rectDefault, NULL, pMenuName);
28:
29: Notes:
30: See MFC sample programs (sample\minmdi, sample\mdi, sample\multi) for
31: complete, working examples of how to call CMDIFrameWnd::Create.
32:
33: The MDICLIENT window (the area where MDI children appear) is created
34: by CMDIFrameWnd::CreateClient which is called from the default
35: WM_CREATE handler for CMDIFrameWnd.
36:
37: When a MDICLIENT window is created it must be told which menu should
38: contain the list of open MDI child windows and where the range of IDs
39: for MDI child windows starts.
40:
41: CMDIFrameWnd::OnCreate assumes the Window menu is the second from
42: the right end of the menu bar (in conformance with the User Interface
43: Style Guide) and that MDI child window IDs should start at
44: AFX_IDM_FIRST_MDICHILD (which is defined to be 0xff00; Windows and
45: Foundation reserve IDs between 0xf000 and 0xffff for system use).
46:
47: If the default menu position is not satisfactory, OnCreate should be
48: overridden and CreateClient called appropriately.
49:
50:
51: -----------------------------------------------------------------------------
52: Creating a MDI Child Window
53: ===========================
54:
55: 1. Define a new class derived from CMDIFrameWnd
56: 2. In the derived class constructor, invoke (for example):
57:
58: Create(NULL, pTitle, 0, rectDefault, pMDIFrameWnd)
59:
60: As above, see the MDI sample applications for complete examples.
61:
62: -----------------------------------------------------------------------------
63: Command Accelerators
64: ====================
65:
66: The default PreTranslateMessage functions handle manually loaded
67: accelerator tables for both MDI child windows and the MDI frame as
68: well as the standard MDI system-command accelerators normally handled
69: by TranslateMDISysAccel.
70:
71: If the active MDI child window has an accelerator table attached to
72: it, that table is searched first for keys as they are pressed. If a
73: key is not found in the child's table, the MDI frame window is
74: checked. If the key is not found in the frame's table either or the
75: frame does not have a table, the key is passed to TranslateMDISysAccel.
76: If that function translates the key, processing of the key stops.
77: Otherwise, the key is sent to the window with the focus via one of
78: OnKeyDown, OnSysKeyDown, OnChar, or OnSysChar.
79:
80: -----------------------------------------------------------------------------
81: Other Functions
82: ===============
83:
84: MDI Frame Windows
85: -----------------
86:
87: GetChildFrame -- returns the active MDI child window or
88: 'this' if there are no children.
89: GetParentFrame -- returns 'this'.
90: MDIActivate -- activates a particular MDI child.
91: MDICascade -- arranges the MDI children so they overlap.
92: MDIGetActive -- returns the active MDI child window or
93: NULL if there are no children.
94: MDIIconArrange -- arranges the MDI child icons.
95: MDIMaximize -- maximizes a particular MDI child window.
96: MDINext -- activate a different MDI child window.
97: MDIRestore -- restores a particular MDI child window.
98: MDISetMenu -- change the menu bar.
99: MDITile -- arranges the MDI children to they don't overlap.
100:
101:
102: MDI Child Windows
103: -----------------
104:
105: GetChildFrame -- returns 'this'.
106: GetParentFrame -- returns the parent MDI frame window.
107: MDIDestroy -- destroys this MDI child window.
108: MDIActivate -- activates this MDI child window.
109: MDIMaximize -- maximizes this MDI child window.
110: MDIRestore -- restores this MDI child window.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.