home *** CD-ROM | disk | FTP | other *** search
/ Building OCXs / Building_OCXs_Que_1995.iso / code / ch07 / cont.cpp < prev    next >
C/C++ Source or Header  |  1995-01-15  |  3KB  |  138 lines

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