home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c08 / listview / dbaccess.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.8 KB  |  145 lines

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