CMDIFrameWnd
The CMDIFrameWnd class provides the functionality of a Windows multiple document interface (MDI) frame window, along with members for managing the window.
To create a useful MDI frame window for your application, derive a class from CMDIFrameWnd. Add member variables to the derived class to store data specific to your application. Implement message-handler member functions and a message map in the derived class to specify what happens when messages are directed to the window.
You can construct an MDI frame window by calling the Create or LoadFrame member function of CFrameWnd.
Before you call Create or LoadFrame, you must construct the frame window object on the heap using the C++ new operator. Before calling Create you can also register a window class with the AfxRegisterWndClass global function to set the icon and class styles for the frame.
Use the Create member function to pass the frame’s creation parameters as immediate arguments.
LoadFrame requires fewer arguments than Create, and instead retrieves most of its default values from resources, including the frame’s caption, icon, accelerator table, and menu. To be accessed by LoadFrame, all these resources must have the same resource ID (for example, IDR_MAINFRAME).
Though MDIFrameWnd is derived from CFrameWnd, a frame window class derived from CMDIFrameWnd need not be declared with DECLARE_DYNCREATE.
The CMDIFrameWnd class inherits much of its default implementation from CFrameWnd. For a detailed list of these features, refer to the CFrameWnd class description. The CMDIFrameWnd class has the following additional features:
An MDI frame window manages the MDICLIENT window, repositioning it in conjunction with control bars. The MDI client window is the direct parent of MDI child frame windows. The WS_HSCROLL and WS_VSCROLL window styles specified on a CMDIFrameWnd apply to the MDI client window rather than the main frame window so the user can scroll the MDI client area (as in the Windows Program Manager, for example).
An MDI frame window owns a default menu that is used as the menu bar when there is no active MDI child window. When there is an active MDI child, the MDI frame window’s menu bar is automatically replaced by the MDI child window menu.
An MDI frame window works in conjunction with the current MDI child window, if there is one. For instance, command messages are delegated to the currently active MDI child before the MDI frame window.
An MDI frame window has default handlers for the following standard Window menu commands:
ID_WINDOW_TILE_VERT
ID_WINDOW_TILE_HORZ
ID_WINDOW_CASCADE
ID_WINDOW_ARRANGE
An MDI frame window also has an implementation of ID_WINDOW_NEW, which creates a new frame and view on the current document. An application can override these default command implementations to customize MDI window handling.
Do not use the C++ delete operator to destroy a frame window. Use CWnd::DestroyWindow instead. The CFrameWnd implementation of PostNcDestroy will delete the C++ object when the window is destroyed. When the user closes the frame window, the default OnClose handler will call DestroyWindow.
For more information on CMDIFrameWnd, see in Visual C++ Programmer’s Guide.
#include <afxwin.h>
Class Members | Base Class | Hierarchy Chart
See Also CWnd, CMDIChildWnd