home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / interact / demo / data.2 / samples / mfc / DBMODEL / DBMODEL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  3.7 KB  |  138 lines

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