ExToolBar.cpp
上传用户:trjx11
上传日期:2021-03-01
资源大小:158k
文件大小:6k
源码类别:

工具条

开发平台:

Visual C++

  1. // ExToolBar.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "ExToolBar.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "ExToolBarDoc.h"
  8. #include "ExToolBarView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CExToolBarApp
  16. BEGIN_MESSAGE_MAP(CExToolBarApp, CWinApp)
  17. //{{AFX_MSG_MAP(CExToolBarApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. //    DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard file based document commands
  23. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  24. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25. // Standard print setup command
  26. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  27. END_MESSAGE_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CExToolBarApp construction
  30. CExToolBarApp::CExToolBarApp()
  31. {
  32. // TODO: add construction code here,
  33. // Place all significant initialization in InitInstance
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // The one and only CExToolBarApp object
  37. CExToolBarApp theApp;
  38. // This identifier was generated to be statistically unique for your app.
  39. // You may change it if you prefer to choose a specific identifier.
  40. // {298735F3-FF1C-11D1-8A9F-000000000000}
  41. static const CLSID clsid =
  42. { 0x298735f3, 0xff1c, 0x11d1, { 0x8a, 0x9f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } };
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CExToolBarApp initialization
  45. BOOL CExToolBarApp::InitInstance()
  46. {
  47. // Initialize OLE libraries
  48. if (!AfxOleInit())
  49. {
  50. AfxMessageBox(IDP_OLE_INIT_FAILED);
  51. return FALSE;
  52. }
  53. AfxEnableControlContainer();
  54. // Standard initialization
  55. // If you are not using these features and wish to reduce the size
  56. //  of your final executable, you should remove from the following
  57. //  the specific initialization routines you do not need.
  58. #ifdef _AFXDLL
  59. Enable3dControls(); // Call this when using MFC in a shared DLL
  60. #else
  61. Enable3dControlsStatic(); // Call this when linking to MFC statically
  62. #endif
  63. // Change the registry key under which our settings are stored.
  64. // You should modify this string to be something appropriate
  65. // such as the name of your company or organization.
  66. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  67. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  68. // Register the application's document templates.  Document templates
  69. //  serve as the connection between documents, frame windows and views.
  70. CMultiDocTemplate* pDocTemplate;
  71. pDocTemplate = new CMultiDocTemplate(
  72. IDR_EXTOOLTYPE,
  73. RUNTIME_CLASS(CExToolBarDoc),
  74. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  75. RUNTIME_CLASS(CExToolBarView));
  76. AddDocTemplate(pDocTemplate);
  77. // Connect the COleTemplateServer to the document template.
  78. //  The COleTemplateServer creates new documents on behalf
  79. //  of requesting OLE containers by using information
  80. //  specified in the document template.
  81. m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
  82. // Register all OLE server factories as running.  This enables the
  83. //  OLE libraries to create objects from other applications.
  84. COleTemplateServer::RegisterAll();
  85. // Note: MDI applications register all server objects without regard
  86. //  to the /Embedding or /Automation on the command line.
  87. // create main MDI Frame window
  88. CMainFrame* pMainFrame = new CMainFrame;
  89. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  90. return FALSE;
  91. m_pMainWnd = pMainFrame;
  92. // Parse command line for standard shell commands, DDE, file open
  93. CCommandLineInfo cmdInfo;
  94. ParseCommandLine(cmdInfo);
  95. // Check to see if launched as OLE server
  96. if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
  97. {
  98. // Application was run with /Embedding or /Automation.  Don't show the
  99. //  main window in this case.
  100. return TRUE;
  101. }
  102. // When a server application is launched stand-alone, it is a good idea
  103. //  to update the system registry in case it has been damaged.
  104. m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
  105. COleObjectFactory::UpdateRegistryAll();
  106. // Dispatch commands specified on the command line
  107. if (!ProcessShellCommand(cmdInfo))
  108. return FALSE;
  109. // The main window has been initialized, so show and update it.
  110. pMainFrame->ShowWindow(m_nCmdShow);
  111. pMainFrame->UpdateWindow();
  112. return TRUE;
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CAboutDlg dialog used for App About
  116. class CAboutDlg : public CDialog
  117. {
  118. public:
  119. CAboutDlg();
  120. // Dialog Data
  121. //{{AFX_DATA(CAboutDlg)
  122. enum { IDD = IDD_ABOUTBOX };
  123. //}}AFX_DATA
  124. // ClassWizard generated virtual function overrides
  125. //{{AFX_VIRTUAL(CAboutDlg)
  126. protected:
  127. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  128. //}}AFX_VIRTUAL
  129. // Implementation
  130. protected:
  131. //{{AFX_MSG(CAboutDlg)
  132. // No message handlers
  133. //}}AFX_MSG
  134. DECLARE_MESSAGE_MAP()
  135. };
  136. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  137. {
  138. //{{AFX_DATA_INIT(CAboutDlg)
  139. //}}AFX_DATA_INIT
  140. }
  141. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  142. {
  143. CDialog::DoDataExchange(pDX);
  144. //{{AFX_DATA_MAP(CAboutDlg)
  145. //}}AFX_DATA_MAP
  146. }
  147. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  148. //{{AFX_MSG_MAP(CAboutDlg)
  149. // No message handlers
  150. //}}AFX_MSG_MAP
  151. END_MESSAGE_MAP()
  152. // App command to run the dialog
  153. void CExToolBarApp::OnAppAbout()
  154. {
  155. CAboutDlg aboutDlg;
  156. aboutDlg.DoModal();
  157. }
  158. /////////////////////////////////////////////////////////////////////////////
  159. // CExToolBarApp commands