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

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "IntelligentMenus.h"
  22. #include "ModernTheme.h"
  23. #include "MainFrm.h"
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CMainFrame
  26. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  27. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  28. //{{AFX_MSG_MAP(CMainFrame)
  29. ON_WM_CREATE()
  30. ON_COMMAND(ID_TOOLS_THEME_CUSTOMTHEME, OnToolsThemeCustomtheme)
  31. ON_UPDATE_COMMAND_UI(ID_TOOLS_THEME_CUSTOMTHEME, OnUpdateToolsThemeCustomtheme)
  32. ON_COMMAND(ID_TOOLS_THEME_OFFICE2003THEME, OnToolsThemeOffice2003theme)
  33. ON_UPDATE_COMMAND_UI(ID_TOOLS_THEME_OFFICE2003THEME, OnUpdateToolsThemeOffice2003theme)
  34. ON_COMMAND(ID_STOP, OnEmptyCommand)
  35. ON_COMMAND(ID_REFRESH, OnEmptyCommand)
  36. ON_COMMAND(ID_HOME, OnEmptyCommand)
  37. ON_COMMAND(ID_SEARCH, OnEmptyCommand)
  38. ON_COMMAND(ID_FAVORITES, OnEmptyCommand)
  39. ON_COMMAND(ID_FONT, OnEmptyCommand)
  40. ON_COMMAND(ID_FILE_EDIT, OnEmptyCommand)
  41. ON_COMMAND(ID_PROPERTIES, OnEmptyCommand)
  42. ON_COMMAND(ID_MUSIC, OnEmptyCommand)
  43. ON_COMMAND(ID_HISTORY, OnEmptyCommand)
  44. ON_COMMAND(ID_SENT, OnEmptyCommand)
  45. ON_COMMAND(ID_FULLSCREEN, OnEmptyCommand)
  46. ON_COMMAND(ID_DISCUSS, OnEmptyCommand)
  47. ON_COMMAND(ID_TOOLS_SYNCROMIZE , OnEmptyCommand)
  48. ON_COMMAND(ID_TOOLS_UPDATE, OnEmptyCommand)
  49. ON_COMMAND(ID_TOOLS_INTERNETOPTIONS, OnEmptyCommand)
  50. ON_COMMAND(ID_TOOLS_SHOWTRASHSCAN, OnEmptyCommand)
  51. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  52. ON_WM_CLOSE()
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. static UINT indicators[] =
  56. {
  57. ID_SEPARATOR,           // status line indicator
  58. ID_INDICATOR_CAPS,
  59. ID_INDICATOR_NUM,
  60. ID_INDICATOR_SCRL,
  61. };
  62. static UINT buttons[] =
  63. {
  64. ID_BACK,
  65. ID_FORWARD,
  66. ID_STOP,
  67. ID_REFRESH,
  68. ID_HOME,
  69. ID_SEARCH,
  70. ID_FAVORITES,
  71. ID_FILE_PRINT,
  72. ID_FONT,
  73. ID_FILE_EDIT,
  74. ID_PROPERTIES,
  75. ID_MUSIC,
  76. ID_HISTORY,
  77. ID_SENT,
  78. ID_FULLSCREEN,
  79. ID_DISCUSS
  80. };
  81. static UINT uHideCmds[] =
  82. {
  83. ID_FILE_CLOSE,
  84. ID_FILE_SAVE,
  85. ID_FILE_SAVE_AS,
  86. ID_FILE_PRINT,
  87. ID_FILE_PRINT_PREVIEW,
  88. ID_FILE_PRINT_SETUP,
  89. ID_EDIT_CUT,
  90. ID_EDIT_COPY,
  91. ID_EDIT_PASTE,
  92. ID_EDIT_FIND,
  93. ID_VIEW_SOURCE,
  94. ID_FULLSCREEN,
  95. ID_TOOLS_UPDATE,
  96. ID_TOOLS_SHOWTRASHSCAN
  97. };
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CMainFrame construction/destruction
  100. CMainFrame::CMainFrame()
  101. {
  102. // TODO: add member initialization code here
  103. }
  104. CMainFrame::~CMainFrame()
  105. {
  106. }
  107. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  108. {
  109. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  110. return -1;
  111. if (!m_wndStatusBar.Create(this) ||
  112. !m_wndStatusBar.SetIndicators(indicators,
  113. sizeof(indicators)/sizeof(UINT)))
  114. {
  115. TRACE0("Failed to create status barn");
  116. return -1;      // fail to create
  117. }
  118. if (!InitCommandBars())
  119. return -1;
  120. CXTPPaintManager::SetCustomTheme(new CModernTheme());
  121. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  122. pIconsInfo->bUseDisabledIcons = TRUE;
  123. pIconsInfo->bUseFadedIcons = FALSE;
  124. CXTPCommandBars* pCommandBars = GetCommandBars();
  125. CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
  126. pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);
  127. CXTPToolBar* pStandardBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop);
  128. if (!pStandardBar ||
  129. !pStandardBar->LoadToolBar(IDR_TOOLBAR_NORMAL_SMALL))
  130. {
  131. TRACE0("Failed to create toolbarn");
  132. return -1;
  133. }
  134. if (XTPImageManager()->IsAlphaIconsSupported())
  135. {
  136. XTPImageManager()->SetIcons(IDR_TOOLBAR_NORMAL_SMALL_ALPHA, buttons, _countof(buttons), CSize(16, 16), xtpImageNormal);
  137. XTPImageManager()->SetIcons(IDR_TOOLBAR_HOT_SMALL_ALPHA, buttons, _countof(buttons), CSize(16, 16), xtpImageHot);
  138. XTPImageManager()->SetIcons(IDR_TOOLBAR_NORMAL_LARGE_ALPHA, buttons, _countof(buttons), CSize(24, 24), xtpImageNormal);
  139. XTPImageManager()->SetIcons(IDR_TOOLBAR_HOT_LARGE_ALPHA, buttons, _countof(buttons), CSize(24, 24), xtpImageHot);
  140. }
  141. else
  142. {
  143. XTPImageManager()->SetMaskColor(RGB(0, 0, 0));
  144. XTPImageManager()->SetIcons(IDR_TOOLBAR_NORMAL_SMALL, buttons, _countof(buttons), CSize(16, 16), xtpImageNormal);
  145. XTPImageManager()->SetIcons(IDR_TOOLBAR_HOT_SMALL, buttons, _countof(buttons), CSize(16, 16), xtpImageHot);
  146. XTPImageManager()->SetIcons(IDR_TOOLBAR_NORMAL_LARGE, buttons, _countof(buttons), CSize(24, 24), xtpImageNormal);
  147. XTPImageManager()->SetIcons(IDR_TOOLBAR_HOT_LARGE, buttons, _countof(buttons), CSize(24, 24), xtpImageHot);
  148. }
  149. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  150. pOptions->szLargeIcons = CSize(24, 24);
  151. pOptions->bLargeIcons = TRUE;
  152. pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice);
  153. pOptions->bAlwaysShowFullMenus = FALSE;
  154. pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));
  155. LoadCommandBars(_T("CommandBars"));
  156. return 0;
  157. }
  158. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  159. {
  160. if( !CFrameWnd::PreCreateWindow(cs) )
  161. return FALSE;
  162. cs.lpszClass = _T("XTPMainFrame");
  163. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  164. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  165. return TRUE;
  166. }
  167. /////////////////////////////////////////////////////////////////////////////
  168. // CMainFrame diagnostics
  169. #ifdef _DEBUG
  170. void CMainFrame::AssertValid() const
  171. {
  172. CFrameWnd::AssertValid();
  173. }
  174. void CMainFrame::Dump(CDumpContext& dc) const
  175. {
  176. CFrameWnd::Dump(dc);
  177. }
  178. #endif //_DEBUG
  179. /////////////////////////////////////////////////////////////////////////////
  180. // CMainFrame message handlers
  181. void CMainFrame::OnEmptyCommand()
  182. {
  183. }
  184. void CMainFrame::OnCustomize()
  185. {
  186. CXTPCustomizeSheet cs(GetCommandBars());
  187. CXTPCustomizeOptionsPage pageOptions(&cs);
  188. cs.AddPage(&pageOptions);
  189. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  190. pCommands->AddCategories(IDR_MAINFRAME);
  191. pCommands->GetControls(_T("File"))->Add(xtpControlButton, ID_FILE_OPEN, _T(""), 1);
  192. pCommands->AddToolbarCategory(_T("Toolbar"), IDR_TOOLBAR_NORMAL_SMALL);
  193. pCommands->InsertAllCommandsCategory();
  194. pCommands->InsertNewMenuCategory();
  195. cs.DoModal();
  196. }
  197. void CMainFrame::OnToolsThemeCustomtheme()
  198. {
  199. CXTPPaintManager::SetCustomTheme(new CModernTheme());
  200. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  201. pIconsInfo->bUseDisabledIcons = TRUE;
  202. pIconsInfo->bUseFadedIcons = FALSE;
  203. GetCommandBars()->RedrawCommandBars();
  204. }
  205. void CMainFrame::OnUpdateToolsThemeCustomtheme(CCmdUI* pCmdUI)
  206. {
  207. pCmdUI->SetCheck(XTPPaintManager()->GetCurrentTheme() != xtpThemeOffice2003);
  208. }
  209. void CMainFrame::OnToolsThemeOffice2003theme()
  210. {
  211. CXTPPaintManager::SetTheme(xtpThemeOffice2003);
  212. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  213. pIconsInfo->bUseDisabledIcons = TRUE;
  214. GetCommandBars()->RedrawCommandBars();
  215. }
  216. void CMainFrame::OnUpdateToolsThemeOffice2003theme(CCmdUI* pCmdUI)
  217. {
  218. pCmdUI->SetCheck(XTPPaintManager()->GetCurrentTheme() == xtpThemeOffice2003);
  219. }
  220. void CMainFrame::OnClose()
  221. {
  222. SaveCommandBars(_T("CommandBars"));
  223. CFrameWnd::OnClose();
  224. }