home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / daolibb / daosampl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-08  |  3.8 KB  |  160 lines

  1. // DaoSample.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DaoSample.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDaoSampleApp
  17.  
  18. BEGIN_MESSAGE_MAP(CDaoSampleApp, CWinApp)
  19.     //{{AFX_MSG_MAP(CDaoSampleApp)
  20.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  21.         // NOTE - the ClassWizard will add and remove mapping macros here.
  22.         //    DO NOT EDIT what you see in these blocks of generated code!
  23.     //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CDaoSampleApp construction
  28.  
  29. CDaoSampleApp::CDaoSampleApp()
  30. {
  31.     // TODO: add construction code here,
  32.     // Place all significant initialization in InitInstance
  33.     CoInitialize(NULL);
  34. }
  35.  
  36. CDaoSampleApp::~CDaoSampleApp()
  37. {
  38.     CoUninitialize();
  39. }
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CDaoSampleApp object
  42.  
  43. CDaoSampleApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CDaoSampleApp initialization
  47.  
  48. BOOL CDaoSampleApp::InitInstance()
  49. {
  50.     // Standard initialization
  51.     // If you are not using these features and wish to reduce the size
  52.     //  of your final executable, you should remove from the following
  53.     //  the specific initialization routines you do not need.
  54.  
  55. #ifdef _AFXDLL
  56.     Enable3dControls();            // Call this when using MFC in a shared DLL
  57. #else
  58.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  59. #endif
  60.  
  61.     // Change the registry key under which our settings are stored.
  62.     // TODO: You should modify this string to be something appropriate
  63.     // such as the name of your company or organization.
  64.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  65.  
  66.  
  67.     // To create the main window, this code creates a new frame window
  68.     // object and then sets it as the application's main window object.
  69.  
  70.     try {
  71.         OpenDatabase("mydata.mdb");
  72.     }
  73.     catch(_com_error& e) {
  74.            Show(e);
  75.         return FALSE;
  76.     }
  77.  
  78.     CMainFrame* pFrame = new CMainFrame;
  79.     m_pMainWnd = pFrame;
  80.  
  81.     // create and load the frame with its resources
  82.  
  83.     pFrame->LoadFrame(IDR_MAINFRAME,
  84.         WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
  85.         NULL);
  86.  
  87.  
  88.  
  89.  
  90.     // The one and only window has been initialized, so show and update it.
  91.     pFrame->ShowWindow(SW_SHOW);
  92.     pFrame->UpdateWindow();
  93.  
  94.     return TRUE;
  95. }
  96.  
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CDaoSampleApp message handlers
  99.  
  100.  
  101.  
  102.  
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CAboutDlg dialog used for App About
  106.  
  107. class CAboutDlg : public CDialog
  108. {
  109. public:
  110.     CAboutDlg();
  111.  
  112. // Dialog Data
  113.     //{{AFX_DATA(CAboutDlg)
  114.     enum { IDD = IDD_ABOUTBOX };
  115.     //}}AFX_DATA
  116.  
  117.     // ClassWizard generated virtual function overrides
  118.     //{{AFX_VIRTUAL(CAboutDlg)
  119.     protected:
  120.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  121.     //}}AFX_VIRTUAL
  122.  
  123. // Implementation
  124. protected:
  125.     //{{AFX_MSG(CAboutDlg)
  126.         // No message handlers
  127.     //}}AFX_MSG
  128.     DECLARE_MESSAGE_MAP()
  129. };
  130.  
  131. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  132. {
  133.     //{{AFX_DATA_INIT(CAboutDlg)
  134.     //}}AFX_DATA_INIT
  135. }
  136.  
  137. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  138. {
  139.     CDialog::DoDataExchange(pDX);
  140.     //{{AFX_DATA_MAP(CAboutDlg)
  141.     //}}AFX_DATA_MAP
  142. }
  143.  
  144. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  145.     //{{AFX_MSG_MAP(CAboutDlg)
  146.         // No message handlers
  147.     //}}AFX_MSG_MAP
  148. END_MESSAGE_MAP()
  149.  
  150. // App command to run the dialog
  151. void CDaoSampleApp::OnAppAbout()
  152. {
  153.     CAboutDlg aboutDlg;
  154.     aboutDlg.DoModal();
  155. }
  156.  
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CDaoSampleApp message handlers
  159.  
  160.