MDI_DynamicBars.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:5k
源码类别:

界面编程

开发平台:

Visual C++

  1. // MDI_DynamicBars.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "MDI_DynamicBars.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "MDI_DynamicBarsDoc.h"
  8. #include "MDI_DynamicBarsView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMDI_DynamicBarsApp
  16. BEGIN_MESSAGE_MAP(CMDI_DynamicBarsApp, CWinApp)
  17. //{{AFX_MSG_MAP(CMDI_DynamicBarsApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. //}}AFX_MSG_MAP
  20. // Standard file based document commands
  21. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  22. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  23. // Standard print setup command
  24. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMDI_DynamicBarsApp construction
  28. CMDI_DynamicBarsApp::CMDI_DynamicBarsApp()
  29. {
  30. // TODO: add construction code here,
  31. // Place all significant initialization in InitInstance
  32. }
  33. /////////////////////////////////////////////////////////////////////////////
  34. // The one and only CMDI_DynamicBarsApp object
  35. CMDI_DynamicBarsApp theApp;
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Prof-UIS advanced options
  38. void CMDI_DynamicBarsApp::SetupUiAdvancedOptions()
  39. {
  40. ASSERT( m_pszRegistryKey != NULL );
  41. ASSERT( m_pszRegistryKey[0] != _T('') );
  42. ASSERT( m_pszProfileName != NULL );
  43. ASSERT( m_pszProfileName[0] != _T('') );
  44. //
  45. // Prof-UIS command manager profile
  46. //
  47. VERIFY(
  48. g_CmdManager->ProfileSetup( m_pszProfileName )
  49. );
  50. //
  51. // Popup menu option: Display menu shadows
  52.     //
  53. CExtPopupMenuWnd::g_bMenuWithShadows = true;
  54. //
  55. // Popup menu option: Display menu cool tips
  56.     //
  57. CExtPopupMenuWnd::g_bMenuShowCoolTips = true;
  58. //
  59. // Popup menu option: Initially hide rarely used items (RUI)
  60.     //
  61. CExtPopupMenuWnd::g_bMenuExpanding = true;
  62. //
  63. // Popup menu option: Display RUI in different style
  64.     //
  65. CExtPopupMenuWnd::g_bMenuHighlightRarely = true;
  66. //
  67. // Popup menu option: Animate when expanding RUI (like Office XP)
  68.     //
  69. CExtPopupMenuWnd::g_bMenuExpandAnimation = true;
  70. //
  71. // Popup menu option: Align to desktop work area (false - to screen area)
  72.     //
  73. CExtPopupMenuWnd::g_bUseDesktopWorkArea = true;
  74. //
  75. // Popup menu option: Popup menu animation effect (when displaying)
  76.     //
  77. CExtPopupMenuWnd::g_DefAnimationType =
  78. CExtPopupMenuWnd::__AT_FADE;
  79. }
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CMDI_DynamicBarsApp initialization
  82. BOOL CMDI_DynamicBarsApp::InitInstance()
  83. {
  84. srand( (unsigned)time( NULL ) );
  85. InitCommonControls();
  86. AfxEnableControlContainer();
  87. // Change the registry key under which our settings are stored.
  88. // TODO: You should modify this string to be something appropriate
  89. // such as the name of your company or organization.
  90. SetRegistryKey( _T("Foss") );
  91. ASSERT( m_pszRegistryKey != NULL );
  92.     // Change the application profile name (usually product name).
  93. // NOTE: The CWinApp class destructor will free the memory automatically.
  94. if( m_pszProfileName != NULL )
  95. free( (void*)m_pszProfileName );
  96. m_pszProfileName =
  97. _tcsdup( _T("MDI_DynamicBars") );
  98. ASSERT( m_pszProfileName != NULL );
  99. //
  100. // Prof-UIS advanced options
  101.     //
  102. SetupUiAdvancedOptions();
  103. LoadStdProfileSettings(16);  // Load standard INI file options (including MRU)
  104. // Register the application's document templates.  Document templates
  105. //  serve as the connection between documents, frame windows and views.
  106. #if (!defined __EXT_MFC_NO_SHELL_DIALOG_FILE)
  107. // make CDocManager using CExtShellDialogFile instead of CFileDialog
  108. ASSERT( m_pDocManager == NULL );
  109. m_pDocManager = new CExtDMFP < CDocManager >;
  110. #endif // (!defined __EXT_MFC_NO_SHELL_DIALOG_FILE)
  111. CMultiDocTemplate* pDocTemplate;
  112. pDocTemplate = new CMultiDocTemplate(
  113. IDR_MDIDOCTYPE,
  114. RUNTIME_CLASS(CMDI_DynamicBarsDoc),
  115. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  116. RUNTIME_CLASS(CMDI_DynamicBarsView)
  117. );
  118. AddDocTemplate(pDocTemplate);
  119. // create main MDI Frame window
  120. CMainFrame* pMainFrame = new CMainFrame;
  121. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  122. return FALSE;
  123. m_pMainWnd = pMainFrame;
  124. // Enable drag/drop open
  125. m_pMainWnd->DragAcceptFiles();
  126. // Enable DDE Execute open
  127. EnableShellOpen();
  128. RegisterShellFileTypes(TRUE);
  129. // Parse command line for standard shell commands, DDE, file open
  130. CCommandLineInfo cmdInfo;
  131. ParseCommandLine(cmdInfo);
  132. // Dispatch commands specified on the command line
  133. if (!ProcessShellCommand(cmdInfo))
  134. return FALSE;
  135. // The main window has been initialized, so show and update it.
  136. pMainFrame->ActivateFrame( SW_SHOWMAXIMIZED );
  137. return TRUE;
  138. }
  139. // App command to run the dialog
  140. void CMDI_DynamicBarsApp::OnAppAbout()
  141. {
  142. #ifndef __EXT_MFC_NO_PROF_UIS_ABOUT_DIALOG
  143. VERIFY( ProfUISAbout() );
  144. #endif // #ifndef __EXT_MFC_NO_PROF_UIS_ABOUT_DIALOG
  145. }
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CMDI_DynamicBarsApp message handlers