home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch08 / ocontain / ocontain.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-22  |  3.8 KB  |  148 lines

  1. // OContain.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "OContain.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "ContainDoc.h"
  9. #include "ContainView.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. // CContainApp
  19.  
  20. BEGIN_MESSAGE_MAP(CContainApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CContainApp)
  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. // CContainApp construction
  33.  
  34. CContainApp::CContainApp()
  35. {
  36.     // TODO: add construction code here,
  37.     // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CContainApp object
  42.  
  43. CContainApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CContainApp initialization
  47.  
  48. BOOL CContainApp::InitInstance()
  49. {
  50.     // Initialize OLE libraries
  51.     if (!AfxOleInit())
  52.     {
  53.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  54.         return FALSE;
  55.     }
  56.  
  57.     // Standard initialization
  58.     // If you are not using these features and wish to reduce the size
  59.     //  of your final executable, you should remove from the following
  60.     //  the specific initialization routines you do not need.
  61.  
  62. #ifdef _AFXDLL
  63.     Enable3dControls();            // Call this when using MFC in a shared DLL
  64. #else
  65.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  66. #endif
  67.  
  68.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  69.  
  70.     // Register the application's document templates.  Document templates
  71.     //  serve as the connection between documents, frame windows and views.
  72.  
  73.     CSingleDocTemplate* pDocTemplate;
  74.     pDocTemplate = new CSingleDocTemplate(
  75.         IDR_MAINFRAME,
  76.         RUNTIME_CLASS(CContainDoc),
  77.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  78.         RUNTIME_CLASS(CContainView));
  79.     pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
  80.     AddDocTemplate(pDocTemplate);
  81.  
  82.     // Parse command line for standard shell commands, DDE, file open
  83.     CCommandLineInfo cmdInfo;
  84.     ParseCommandLine(cmdInfo);
  85.  
  86.     // Dispatch commands specified on the command line
  87.     if (!ProcessShellCommand(cmdInfo))
  88.         return FALSE;
  89.  
  90.     return TRUE;
  91. }
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CAboutDlg dialog used for App About
  95.  
  96. class CAboutDlg : public CDialog
  97. {
  98. public:
  99.     CAboutDlg();
  100.  
  101. // Dialog Data
  102.     //{{AFX_DATA(CAboutDlg)
  103.     enum { IDD = IDD_ABOUTBOX };
  104.     //}}AFX_DATA
  105.  
  106.     // ClassWizard generated virtual function overrides
  107.     //{{AFX_VIRTUAL(CAboutDlg)
  108.     protected:
  109.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  110.     //}}AFX_VIRTUAL
  111.  
  112. // Implementation
  113. protected:
  114.     //{{AFX_MSG(CAboutDlg)
  115.         // No message handlers
  116.     //}}AFX_MSG
  117.     DECLARE_MESSAGE_MAP()
  118. };
  119.  
  120. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  121. {
  122.     //{{AFX_DATA_INIT(CAboutDlg)
  123.     //}}AFX_DATA_INIT
  124. }
  125.  
  126. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  127. {
  128.     CDialog::DoDataExchange(pDX);
  129.     //{{AFX_DATA_MAP(CAboutDlg)
  130.     //}}AFX_DATA_MAP
  131. }
  132.  
  133. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  134.     //{{AFX_MSG_MAP(CAboutDlg)
  135.         // No message handlers
  136.     //}}AFX_MSG_MAP
  137. END_MESSAGE_MAP()
  138.  
  139. // App command to run the dialog
  140. void CContainApp::OnAppAbout()
  141. {
  142.     CAboutDlg aboutDlg;
  143.     aboutDlg.DoModal();
  144. }
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CContainApp commands
  148.