home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / ipdrive / ipdrive.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  150 lines

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