|
|
1.1 root 1: // minmdi.cpp : Defines the class behaviors for MinMDI.
2: // This application is the simplest Multiple Document Interface
3: // (MDI) program. It demonstrates how the CMDIFrameWnd and
4: // CMDIChildWnd classes can be used together to make an MDI
5: // application.
6: //
7: // This is a part of the Microsoft Foundation Classes C++ library.
8: // Copyright (C) 1992 Microsoft Corporation
9: // All rights reserved.
10: //
11: // This source code is only intended as a supplement to the
12: // Microsoft Foundation Classes Reference and Microsoft
13: // QuickHelp documentation provided with the library.
14: // See these sources for detailed information regarding the
15: // Microsoft Foundation Classes product.
16:
17: #include <afxwin.h>
18: #include "resource.h"
19:
20: #include "minmdi.h"
21:
22: /////////////////////////////////////////////////////////////////////////////
23:
24: // Create one global CTheApp object. Once created, it takes care of itself.
25: //
26: CTheApp theApp;
27:
28: /////////////////////////////////////////////////////////////////////////////
29: // CMainWindow
30:
31: // CMainWindow constructor:
32: // Create the window, with appropriate style, default size, and the
33: // "MainMenu" menu and "MainAccelTable" resources (see minmdi.rc).
34: //
35: CMainWindow::CMainWindow()
36: {
37: LoadAccelTable("MainAccelTable");
38: Create(NULL, "Minimal MDI Sample Application", WS_OVERLAPPEDWINDOW,
39: rectDefault, NULL, "MainMenu");
40: }
41:
42: // OnAbout:
43: // Invoke the "AboutBox" modal dialog (see minmdi.rc and about.dlg).
44: //
45: void CMainWindow::OnAbout()
46: {
47: CModalDialog about("AboutBox", this);
48: about.DoModal();
49: }
50:
51: // OnNewWindow:
52: // Create and show a new CMDIChildWnd object and window.
53: //
54: void CMainWindow::OnNewWindow()
55: {
56: CMDIChildWnd* pWnd = new CMDIChildWnd;
57:
58: if (pWnd->Create(NULL, "Child Window", 0, rectDefault, this))
59: pWnd->ShowWindow(SW_SHOW);
60: else
61: MessageBeep(0);
62: }
63:
64: // CMainWindow message map:
65: // Associate two WM_COMMAND menu choices to member functions.
66: //
67: BEGIN_MESSAGE_MAP(CMainWindow, CMDIFrameWnd)
68: ON_COMMAND(IDM_ABOUT, OnAbout)
69: ON_COMMAND(IDM_WINDOWNEW, OnNewWindow)
70: END_MESSAGE_MAP()
71:
72: /////////////////////////////////////////////////////////////////////////////
73: // CTheApp
74:
75: // InitInstance:
76: // Create and show the main window.
77: //
78: BOOL CTheApp::InitInstance()
79: {
80: m_pMainWnd = new CMainWindow();
81: m_pMainWnd->ShowWindow(m_nCmdShow);
82: m_pMainWnd->UpdateWindow();
83: return TRUE;
84: }
85:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.