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

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