home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / vcoledb / consumer / catdb / catdb.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  4.2 KB  |  163 lines

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