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

  1. // oldbars.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 "oldbars.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "oldbadoc.h"
  18. #include "oldbavw.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // COldbarsApp
  27.  
  28. BEGIN_MESSAGE_MAP(COldbarsApp, CWinApp)
  29.     //{{AFX_MSG_MAP(COldbarsApp)
  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.     // Standard print setup command
  38.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // COldbarsApp construction
  43.  
  44. COldbarsApp::COldbarsApp()
  45. {
  46.     // TODO: add construction code here,
  47.     // Place all significant initialization in InitInstance
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // The one and only COldbarsApp object
  52.  
  53. COldbarsApp theApp;
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // COldbarsApp initialization
  57.  
  58. BOOL COldbarsApp::InitInstance()
  59. {
  60.     // Standard initialization
  61.     // If you are not using these features and wish to reduce the size
  62.     //  of your final executable, you should remove from the following
  63.     //  the specific initialization routines you do not need.
  64.  
  65.     Enable3dControls();
  66.  
  67.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  68.  
  69.     // Register the application's document templates.  Document templates
  70.     //  serve as the connection between documents, frame windows and views.
  71.  
  72.     CMultiDocTemplate* pDocTemplate;
  73.     pDocTemplate = new CMultiDocTemplate(
  74.         IDR_OLDBARTYPE,
  75.         RUNTIME_CLASS(COldbarsDoc),
  76.         RUNTIME_CLASS(CMDIChildWnd),          // standard MDI child frame
  77.         RUNTIME_CLASS(COldbarsView));
  78.     AddDocTemplate(pDocTemplate);
  79.  
  80.     // create main MDI Frame window
  81.     CMainFrame* pMainFrame = new CMainFrame;
  82.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  83.         return FALSE;
  84.     m_pMainWnd = pMainFrame;
  85.  
  86.     // create a new (empty) document
  87.     // On the Macintosh, this call isn't required, since the Finder is
  88.     //  already sending the app a message to open a new document.
  89.     OnFileNew();
  90.  
  91.     if (m_lpCmdLine[0] != '\0')
  92.     {
  93.         // TODO: add command line processing here
  94.     }
  95.  
  96.     // The main window has been initialized, so show and update it.
  97.     pMainFrame->ShowWindow(m_nCmdShow);
  98.     pMainFrame->UpdateWindow();
  99.  
  100.     return TRUE;
  101. }
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CAboutDlg dialog used for App About
  105.  
  106. class CAboutDlg : public CDialog
  107. {
  108. public:
  109.     CAboutDlg();
  110.  
  111. // Dialog Data
  112.     //{{AFX_DATA(CAboutDlg)
  113.     enum { IDD = IDD_ABOUTBOX };
  114.     //}}AFX_DATA
  115.  
  116. // Implementation
  117. protected:
  118.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  119.     //{{AFX_MSG(CAboutDlg)
  120.         // No message handlers
  121.     //}}AFX_MSG
  122.     DECLARE_MESSAGE_MAP()
  123. };
  124.  
  125. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  126. {
  127.     //{{AFX_DATA_INIT(CAboutDlg)
  128.     //}}AFX_DATA_INIT
  129. }
  130.  
  131. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  132. {
  133.     CDialog::DoDataExchange(pDX);
  134.     //{{AFX_DATA_MAP(CAboutDlg)
  135.     //}}AFX_DATA_MAP
  136. }
  137.  
  138. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  139.     //{{AFX_MSG_MAP(CAboutDlg)
  140.         // No message handlers
  141.     //}}AFX_MSG_MAP
  142. END_MESSAGE_MAP()
  143.  
  144. // App command to run the dialog
  145. void COldbarsApp::OnAppAbout()
  146. {
  147.     CAboutDlg aboutDlg;
  148.     aboutDlg.DoModal();
  149. }
  150.  
  151. /////////////////////////////////////////////////////////////////////////////
  152. // COldbarsApp commands
  153.