The bulk of FrameWndProc is devoted to processing WM_COMMAND messages that signal menu selections. As usual, the wParam parameter to FrameWndProc contains the menu ID number.
For wParam values of IDM_NEWHELLO and IDM_NEWRECT, FrameWndProc must create a new document window. This involves initializing the fields of an MDICREATESTRUCT structure (most of which correspond to CreateWindow parameters) and sending the client window a WM_MDICREATE message with lParam set to a pointer to this structure. The client window then creates the child document window.
Normally, the szTitle field of the MDICREATESTRUCT structure would be the filename corresponding to the document. The style field can be set to the window styles WS_HSCROLL or WS_VSCROLL or both to include scroll bars in the document window. The style field can also include WS_MINIMIZE or WS_MAXIMIZE to initially display the document window in a minimized or maximized state.
(The lParam field of the MDICREATESTRUCT structure provides a way for the frame window and the child window to share some variables. This field could be set to a local or global memory handle that references a block of memory containing a structure. During the WM_CREATE message in the child document window, lParam is a pointer to a CREATESTRUCT structure, and the lpCreateParams field of this structure is a pointer to the MDICREATESTRUCT structure used to create the window.)
On receipt of the WM_MDICREATE message, the client window creates the child document window and adds the title of the window to the bottom of the submenu specified in the MDICLIENTSTRUCT structure used to create the client window. When the MDIDEMO program creates its first document window, this is the File submenu of the MdiMenuInit menu. We'll see later how this document list gets moved to the Window submenu of the MdiMenuHello and MdiMenuRect menus.
Up to nine documents can be listed on the menu, each preceded by an underlined number from 1 to 9. If more than nine document windows are created, this list is followed by a ”More windows“ item on the menu. This item invokes a dialog box with a list box that lists all the document windows. The maintenance of this document list is one of the nicest features of the Windows 3 MDI support.