home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c05 / dynamenu / dynamenu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.4 KB  |  132 lines

  1. // DynaMenu.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DynaMenu.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "DynaMDoc.h"
  9. #include "DynaView.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMenusDynamicApp
  19.  
  20. BEGIN_MESSAGE_MAP(CMenusDynamicApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CMenusDynamicApp)
  22.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard file based document commands
  27.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMenusDynamicApp construction
  33.  
  34. CMenusDynamicApp::CMenusDynamicApp()
  35. {
  36. }
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // The one and only CMenusDynamicApp object
  40.  
  41. CMenusDynamicApp theApp;
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CMenusDynamicApp initialization
  45.  
  46. BOOL CMenusDynamicApp::InitInstance()
  47. {
  48.     // Standard initialization
  49.     // If you are not using these features and wish to reduce the size
  50.     //  of your final executable, you should remove from the following
  51.     //  the specific initialization routines you do not need.
  52.  
  53.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  54.  
  55.     // Register the application's document templates.  Document templates
  56.     //  serve as the connection between documents, frame windows and views.
  57.  
  58.     CSingleDocTemplate* pDocTemplate;
  59.     pDocTemplate = new CSingleDocTemplate(
  60.         IDR_MAINFRAME,
  61.         RUNTIME_CLASS(CMenusDynamicDoc),
  62.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  63.         RUNTIME_CLASS(CMenusDynamicView));
  64.     AddDocTemplate(pDocTemplate);
  65.  
  66.     // Parse command line for standard shell commands, DDE, file open
  67.     CCommandLineInfo cmdInfo;
  68.     ParseCommandLine(cmdInfo);
  69.  
  70.     // Dispatch commands specified on the command line
  71.     if (!ProcessShellCommand(cmdInfo))
  72.         return FALSE;
  73.  
  74.     return TRUE;
  75. }
  76.  
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CAboutDlg dialog used for App About
  79.  
  80. class CAboutDlg : public CDialog
  81. {
  82. public:
  83.     CAboutDlg();
  84.  
  85. // Dialog Data
  86.     //{{AFX_DATA(CAboutDlg)
  87.     enum { IDD = IDD_ABOUTBOX };
  88.     //}}AFX_DATA
  89.  
  90.     // ClassWizard generated virtual function overrides
  91.     //{{AFX_VIRTUAL(CAboutDlg)
  92.     protected:
  93.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  94.     //}}AFX_VIRTUAL
  95.  
  96. // Implementation
  97. protected:
  98.     //{{AFX_MSG(CAboutDlg)
  99.         // No message handlers
  100.     //}}AFX_MSG
  101.     DECLARE_MESSAGE_MAP()
  102. };
  103.  
  104. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  105. {
  106.     //{{AFX_DATA_INIT(CAboutDlg)
  107.     //}}AFX_DATA_INIT
  108. }
  109.  
  110. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  111. {
  112.     CDialog::DoDataExchange(pDX);
  113.     //{{AFX_DATA_MAP(CAboutDlg)
  114.     //}}AFX_DATA_MAP
  115. }
  116.  
  117. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  118.     //{{AFX_MSG_MAP(CAboutDlg)
  119.         // No message handlers
  120.     //}}AFX_MSG_MAP
  121. END_MESSAGE_MAP()
  122.  
  123. // App command to run the dialog
  124. void CMenusDynamicApp::OnAppAbout()
  125. {
  126.     CAboutDlg aboutDlg;
  127.     aboutDlg.DoModal();
  128. }
  129.  
  130. /////////////////////////////////////////////////////////////////////////////
  131. // CMenusDynamicApp commands
  132.