MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:6k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "TabbedToolbar.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMainFrame
  13. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  14. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  15. //{{AFX_MSG_MAP(CMainFrame)
  16. // NOTE - the ClassWizard will add and remove mapping macros here.
  17. //    DO NOT EDIT what you see in these blocks of generated code !
  18. ON_WM_CREATE()
  19. ON_WM_CLOSE()
  20. //}}AFX_MSG_MAP
  21. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  22. ON_COMMAND_RANGE(IDR_ICO7511, IDR_ICO9611, OnEmptyCommand)
  23. ON_COMMAND_RANGE(IDR_ICO9621, IDR_ICO9807, OnEmptyCommand)
  24. ON_COMMAND_RANGE(ID_BUTTON32771, ID_BUTTON_DELETE, OnEmptyCommand)
  25. END_MESSAGE_MAP()
  26. static UINT indicators[] =
  27. {
  28. ID_SEPARATOR,           // status line indicator
  29. ID_INDICATOR_CAPS,
  30. ID_INDICATOR_NUM,
  31. ID_INDICATOR_SCRL,
  32. };
  33. static UINT StandardIcons[] =
  34. {
  35. IDR_ICO20513,
  36. IDR_ICO11056,
  37. IDR_ICO9809,
  38. IDR_ICO9807,
  39. IDR_ICO9806,
  40. IDR_ICO9805,
  41. IDR_ICO9803,
  42. IDR_ICO9802,
  43. IDR_ICO9801,
  44. ID_SEPARATOR,
  45. IDR_ICO9800,
  46. IDR_ICO9746,
  47. IDR_ICO9720,
  48. IDR_ICO9718,
  49. IDR_ICO9717,
  50. IDR_ICO9710,
  51. IDR_ICO9704,
  52. IDR_ICO9703,
  53. IDR_ICO9683,
  54. IDR_ICO9673
  55. };
  56. static UINT AdvancedIcons[] =
  57. {
  58. IDR_ICO9673,
  59. IDR_ICO9621,
  60. IDR_ICO9619,
  61. ID_SEPARATOR,
  62. IDR_ICO9618,
  63. IDR_ICO9617,
  64. IDR_ICO9611,
  65. IDR_ICO9609,
  66. IDR_ICO9608,
  67. IDR_ICO9607,
  68. ID_SEPARATOR,
  69. IDR_ICO9606,
  70. IDR_ICO9600,
  71. IDR_ICO9505,
  72. IDR_ICO9504
  73. };
  74. static UINT OtherIcons[] =
  75. {
  76. IDR_ICO9502,
  77. IDR_ICO9410,
  78. IDR_ICO9409,
  79. IDR_ICO9403,
  80. IDR_ICO8536,
  81. ID_SEPARATOR,
  82. IDR_ICO8044,
  83. IDR_ICO7721,
  84. IDR_ICO7612,
  85. IDR_ICO7611,
  86. IDR_ICO7610,
  87. IDR_ICO7519,
  88. IDR_ICO7518,
  89. ID_SEPARATOR,
  90. IDR_ICO7513,
  91. IDR_ICO7511
  92. };
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CMainFrame construction/destruction
  95. CMainFrame::CMainFrame()
  96. {
  97. // TODO: add member initialization code here
  98. }
  99. CMainFrame::~CMainFrame()
  100. {
  101. }
  102. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  103. {
  104. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  105. return -1;
  106. // Create Status bar.
  107. // Important: All control bars including the Status Bar
  108. // must be created before CommandBars....
  109. if (!m_wndStatusBar.Create(this) ||
  110. !m_wndStatusBar.SetIndicators(indicators,
  111. sizeof(indicators)/sizeof(UINT)))
  112. {
  113. TRACE0("Failed to create status barn");
  114. return -1;      // fail to create
  115. }
  116. // Initialize the command bars
  117. if (!InitCommandBars())
  118. return -1;
  119. // Get a pointer to the command bars object.
  120. CXTPCommandBars* pCommandBars = GetCommandBars();
  121. if(pCommandBars == NULL)
  122. {
  123. TRACE0("Failed to create command bars object.n");
  124. return -1;      // fail to create
  125. }
  126. // Add the menu bar
  127. CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
  128. _T("Menu Bar"), IDR_MAINFRAME);
  129. if(pMenuBar == NULL)
  130. {
  131. TRACE0("Failed to create menu bar.n");
  132. return -1;      // fail to create
  133. }
  134. pMenuBar->SetFlags(xtpFlagAddMDISysPopup);
  135. // Create ToolBar
  136. CXTPTabToolBar* pToolBar = (CXTPTabToolBar*)
  137. pCommandBars->Add(_T("Standard"), xtpBarTop, RUNTIME_CLASS(CXTPTabToolBar));
  138. pToolBar->SetBarID(IDR_MAINFRAME);
  139. CXTPTabManagerItem* pItem = pToolBar->InsertCategory(0, _T("Standard"), StandardIcons, _countof(StandardIcons));
  140. pItem->SetImageIndex(IDR_MAINFRAME);
  141. pItem = pToolBar->InsertCategory(1, _T("Advanced"), AdvancedIcons, _countof(AdvancedIcons));
  142. pItem->SetImageIndex(IDR_MAINFRAME);
  143. pItem = pToolBar->InsertCategory(2, _T("Other"), OtherIcons, _countof(OtherIcons));
  144. pItem->SetImageIndex(IDR_MAINFRAME);
  145. pItem->SetTooltip(_T("Other icons"));
  146. if (pCommandBars->GetImageManager()->IsAlphaIconsSupported())
  147. pToolBar->InsertCategory(4, _T("User Tools"), IDR_TOOLBAR_USER);
  148. pCommandBars->GetImageManager()->SetIcon(IDR_MAINFRAME, IDR_MAINFRAME);
  149. pToolBar->GetPaintManager()->m_bShowIcons = FALSE;
  150. pToolBar->GetPaintManager()->EnableToolTips(xtpTabToolTipAlways);
  151. pToolBar->SetMinimumWidth(300);
  152. // Set Office 2003 Theme
  153. CXTPPaintManager::SetTheme(xtpThemeOffice2003);
  154. //CXTPPaintManager::SetTheme(xtpThemeWhidbey);
  155. pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
  156. pCommandBars->GetCommandBarsOptions()->bLargeIcons = TRUE;
  157. // Load the previous state for toolbars and menus.
  158. LoadCommandBars(_T("CommandBars"));
  159. pToolBar->UpdateTabs(pToolBar->GetItem(0));
  160. return 0;
  161. }
  162. void CMainFrame::OnClose()
  163. {
  164. // Save the current state for toolbars and menus.
  165. SaveCommandBars(_T("CommandBars"));
  166. CMDIFrameWnd::OnClose();
  167. }
  168. void CMainFrame::OnCustomize()
  169. {
  170. // Get a pointer to the command bars object.
  171. CXTPCommandBars* pCommandBars = GetCommandBars();
  172. if(pCommandBars != NULL)
  173. {
  174. // Instanciate the customize dialog object.
  175. CXTPCustomizeSheet dlg(pCommandBars);
  176. // Add the keyboard page to the customize dialog.
  177. CXTPCustomizeKeyboardPage pageKeyboard(&dlg);
  178. dlg.AddPage(&pageKeyboard);
  179. pageKeyboard.AddCategories(IDR_TABBEDTYPE);
  180. // Add the options page to the customize dialog.
  181. CXTPCustomizeOptionsPage pageOptions(&dlg);
  182. dlg.AddPage(&pageOptions);
  183. // Add the commands page to the customize dialog.
  184. CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
  185. pCommands->AddCategories(IDR_TABBEDTYPE);
  186. // Use the command bar manager to initialize the
  187. // customize dialog.
  188. pCommands->InsertAllCommandsCategory();
  189. pCommands->InsertBuiltInMenus(IDR_TABBEDTYPE);
  190. pCommands->InsertNewMenuCategory();
  191. // Dispaly the dialog.
  192. dlg.DoModal();
  193. }
  194. }
  195. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  196. {
  197. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  198. return FALSE;
  199. cs.lpszClass = _T("XTPMainFrame");
  200. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  201. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  202. return TRUE;
  203. }
  204. /////////////////////////////////////////////////////////////////////////////
  205. // CMainFrame diagnostics
  206. #ifdef _DEBUG
  207. void CMainFrame::AssertValid() const
  208. {
  209. CMDIFrameWnd::AssertValid();
  210. }
  211. void CMainFrame::Dump(CDumpContext& dc) const
  212. {
  213. CMDIFrameWnd::Dump(dc);
  214. }
  215. #endif //_DEBUG
  216. /////////////////////////////////////////////////////////////////////////////
  217. // CMainFrame message handlers
  218. void CMainFrame::OnEmptyCommand(UINT)
  219. {
  220. }