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

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