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

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "RibbonSample.h"
  5. #include "MainFrm.h"
  6. #include "Galleryitems.h"
  7. #include "WorkspaceView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMainFrame
  15. IMPLEMENT_DYNCREATE(CMainFrame, CXTPFrameWnd)
  16. BEGIN_MESSAGE_MAP(CMainFrame, CXTPFrameWnd)
  17. //{{AFX_MSG_MAP(CMainFrame)
  18. ON_WM_CREATE()
  19. ON_WM_CLOSE()
  20. ON_COMMAND(ID_OPTIONS_ANIMATION, OnOptionsAnimation)
  21. ON_UPDATE_COMMAND_UI(ID_OPTIONS_ANIMATION, OnUpdateOptionsAnimation)
  22. ON_COMMAND(ID_OPTIONS_RIGHTTOLEFT, OnOptionsRighttoleft)
  23. ON_UPDATE_COMMAND_UI(ID_OPTIONS_RIGHTTOLEFT, OnUpdateOptionsRighttoleft)
  24. ON_COMMAND_RANGE(ID_OPTIONS_STYLEBLUE, ID_OPTIONS_STYLEAQUA, OnOptionsStyle)
  25. ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_STYLEBLUE, ID_OPTIONS_STYLEAQUA, OnUpdateOptionsStyle)
  26. ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FONT_SYSTEM, ID_OPTIONS_FONT_EXTRALARGE, OnUpdateOptionsFont)
  27. ON_COMMAND_RANGE(ID_OPTIONS_FONT_SYSTEM, ID_OPTIONS_FONT_EXTRALARGE, OnOptionsFont)
  28. ON_COMMAND(ID_OPTIONS_FONT_AUTORESIZEICONS, OnAutoResizeIcons)
  29. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FONT_AUTORESIZEICONS, OnUpdateAutoResizeIcons)
  30. ON_COMMAND(ID_OPTIONS_FRAMETHEME, OnFrameTheme)
  31. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMETHEME, OnUpdateFrameTheme)
  32. ON_COMMAND(ID_TOGGLE_GROUPS, OnToggleGroups)
  33. ON_COMMAND(XTP_ID_RIBBONCUSTOMIZE_MINIMIZE, OnToggleGroups)
  34. //}}AFX_MSG_MAP
  35. ON_COMMAND(ID_THEMES_THEMES, OnSwitchCommand)
  36. ON_UPDATE_COMMAND_UI(ID_THEMES_THEMES, OnUpdateSwitchCommand)
  37. ON_COMMAND_RANGE(ID_THEMES_FONTS, ID_ARRANGE_TEXTWRAPPING, OnEmptyCommandRange)
  38. ON_COMMAND(ID_FILE_SEND_MAIL, OnEmptyCommand)
  39. ON_COMMAND(ID_FILE_SEND_INTERNETFAX, OnEmptyCommand)
  40. ON_COMMAND(ID_STYLES_CHANGE, OnEmptyCommand)
  41. ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RULER, ID_VIEW_THUMBNAILS, OnUpdateViewShowHide)
  42. ON_COMMAND_RANGE(ID_VIEW_RULER, ID_VIEW_THUMBNAILS, OnViewShowHide)
  43. ON_COMMAND_EX(ID_VIEW_MESSAGE_BAR, CFrameWnd::OnBarCheck)
  44. ON_UPDATE_COMMAND_UI(ID_VIEW_MESSAGE_BAR, CFrameWnd::OnUpdateControlBarMenu)
  45. ON_NOTIFY(TCN_SELCHANGE, XTP_ID_RIBBONCONTROLTAB, OnRibbonTabChanged)
  46. ON_NOTIFY(TCN_SELCHANGING, XTP_ID_RIBBONCONTROLTAB, OnRibbonTabChanging)
  47. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  48. ON_COMMAND(ID_APP_OPTIONS, OnCustomize)
  49. ON_COMMAND(XTP_ID_RIBBONCUSTOMIZE, OnCustomizeQuickAccess)
  50. ON_XTP_EXECUTE(ID_GALLERY_STYLES, OnGalleryStyles)
  51. ON_UPDATE_COMMAND_UI(ID_GALLERY_STYLES, OnUpdateGalleryStyles)
  52. ON_XTP_EXECUTE(ID_GALLERY_COLUMNS, OnGalleryColumns)
  53. ON_UPDATE_COMMAND_UI(ID_GALLERY_COLUMNS, OnUpdateGalleryColumns)
  54. ON_XTP_EXECUTE(ID_GALLERY_SHAPES, OnGalleryShapes)
  55. ON_UPDATE_COMMAND_UI(ID_GALLERY_SHAPES, OnUpdateGalleryShapes)
  56. ON_XTP_EXECUTE(ID_GALLERY_STYLESET, OnGalleryStyleSet)
  57. ON_UPDATE_COMMAND_UI(ID_GALLERY_STYLESET, OnUpdateGalleryStyleSet)
  58. ON_XTP_EXECUTE(ID_GALLERY_COLORS, OnGalleryThemeColors)
  59. ON_UPDATE_COMMAND_UI(ID_GALLERY_COLORS, OnUpdateGalleryThemeColors)
  60. ON_XTP_EXECUTE(ID_GALLERY_FONTS, OnGalleryThemeFonts)
  61. ON_UPDATE_COMMAND_UI(ID_GALLERY_FONTS, OnUpdateGalleryThemeFonts)
  62. ON_XTP_CREATECONTROL()
  63. ON_COMMAND_RANGE(ID_SWITCH_PRINTLAYOUT, ID_SWITCH_DRAFT, OnStatusBarSwitchView)
  64. ON_COMMAND(ID_INDICATOR_MACRORECORDING, OnMacroClick)
  65. ON_UPDATE_COMMAND_UI(ID_INDICATOR_CAPSLOCK, OnUpdateKeyIndicator)
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CMainFrame construction/destruction
  69. //#define _SAVE_TO_XML
  70. CMainFrame::CMainFrame()
  71. {
  72. TCHAR szStylesPath[_MAX_PATH];
  73. VERIFY(::GetModuleFileName(
  74. AfxGetApp()->m_hInstance, szStylesPath, _MAX_PATH));
  75. CString csStylesPath(szStylesPath);
  76. int nIndex  = csStylesPath.ReverseFind(_T('\'));
  77. if (nIndex > 0) {
  78. csStylesPath = csStylesPath.Left(nIndex);
  79. }
  80. else {
  81. csStylesPath.Empty();
  82. }
  83. m_csStylesPath += csStylesPath + _T("\Styles\");
  84. m_bChecked = FALSE;
  85. m_bAnimation = TRUE;
  86. m_bLayoutRTL = FALSE;
  87. ZeroMemory(&m_bOptions, sizeof(m_bOptions));
  88. // get path of executable
  89. LPTSTR lpszExt = _tcsrchr(szStylesPath, '.');
  90. lstrcpy(lpszExt, _T(".xml"));
  91. m_strIniFileName = szStylesPath;
  92. m_nColumns = 0;
  93. m_pItemsShapes = 0;
  94. m_pItemsStyles = 0;
  95. m_pItemsStyleSet = 0;
  96. m_pItemsThemeColors = 0;
  97. m_pItemsThemeFonts = 0;
  98. m_pItemsFontTextColor = 0;
  99. m_pItemsFontBackColor = 0;
  100. m_pItemsFontFace = 0;
  101. m_pItemsFontSize = 0;
  102. m_pItemsColumns = 0;
  103. m_nRibbonStyle = ID_OPTIONS_STYLEBLUE;
  104. }
  105. CMainFrame::~CMainFrame()
  106. {
  107. }
  108. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  109. {
  110. if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1)
  111. return -1;
  112. XTPPaintManager()->SetTheme(xtpThemeRibbon);
  113. if (!CreateStatusBar())
  114. return -1;
  115. if (!InitCommandBars())
  116. return -1;
  117. CXTPCommandBars* pCommandBars = GetCommandBars();
  118. m_wndStatusBar.SetCommandBars(pCommandBars);
  119. // To Set theme for individual CommandBars
  120. // pCommandBars->SetTheme(xtpThemeRibbon);
  121. //////////////////////////////////////////////////////////////////////////
  122. // IMPORTANT:
  123. // Ribbon bitmaps resources by default located in application executable. 
  124. //
  125. // You also can specify handle to find ribbon resources:
  126. //((CXTPOffice2007Theme*)XTPPaintManager())->SetImageHandle(hHandle);
  127. //HMODULE hModule = LoadLibrary(m_csStylesPath + _T("Office2007Blue.dll"));
  128. //((CXTPOffice2007Theme*)pCommandBars->GetPaintManager())->SetImageHandle(hModule);
  129. CXTPToolTipContext* pToolTipContext = GetCommandBars()->GetToolTipContext();
  130. pToolTipContext->SetStyle(xtpToolTipOffice2007);
  131. pToolTipContext->ShowTitleAndDescription();
  132. pToolTipContext->ShowImage(TRUE, 0);
  133. pToolTipContext->SetMargin(CRect(2, 2, 2, 2));
  134. pToolTipContext->SetMaxTipWidth(180);
  135. pToolTipContext->SetFont(pCommandBars->GetPaintManager()->GetIconFont());
  136. pToolTipContext->SetDelayTime(TTDT_INITIAL, 900);
  137. LoadIcons();
  138. pCommandBars->GetPaintManager()->m_bAutoResizeIcons = TRUE;
  139. pCommandBars->GetCommandBarsOptions()->bToolBarAccelTips = TRUE;
  140. pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
  141. CreateGalleries();
  142. if (!CreateRibbonBar())
  143. {
  144. TRACE0("Failed to create ribbonn");
  145. return -1;
  146. }
  147. CreateMiniToolBar();
  148. if (!CreateMessageBar())
  149. return -1;
  150. #ifndef _SAVE_TO_XML
  151. LoadCommandBars(_T("CommandBars2"));
  152. #else
  153. CXTPPropExchangeXMLNode px(TRUE, 0, _T("Settings"));
  154. if (px.LoadFromFile(m_strIniFileName))
  155. {
  156. CXTPPropExchangeSection pxCommandBars(px.GetSection(_T("CommandBars")));
  157. XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; 
  158. param.bSerializeControls = TRUE;
  159. param.bSerializeOptions = TRUE;
  160. GetCommandBars()->DoPropExchange(&pxCommandBars, &param);
  161. }
  162. #endif
  163. ((CWorkspaceView*)GetDlgItem(AFX_IDW_PANE_FIRST))->
  164. m_wndScrollBar[SB_VERT].SetCommandBars(pCommandBars);
  165. ((CWorkspaceView*)GetDlgItem(AFX_IDW_PANE_FIRST))->
  166. m_wndScrollBar[SB_HORZ].SetCommandBars(pCommandBars);
  167. pCommandBars->GetCommandBarsOptions()->bShowKeyboardTips = TRUE;
  168. //HMODULE hModule = AfxGetInstanceHandle();
  169. //((CXTPOffice2007Theme*)GetCommandBars()->GetPaintManager())->SetImageHandle(hModule, _T("OFFICE2007SILVER.INI"));
  170. CreateDockingPane();
  171. return 0;
  172. }
  173. void CMainFrame::CreateDockingPane()
  174. {
  175. m_paneManager.InstallDockingPanes(this);
  176. m_paneManager.SetTheme(xtpPaneThemeWord2007);
  177. m_paneManager.SetThemedFloatingFrames(TRUE);
  178. m_paneManager.SetShowContentsWhileDragging(TRUE);
  179. m_paneManager.UseSplitterTracker(FALSE);
  180. CXTPDockingPaneMiniWnd::m_bShowPinButton = FALSE;
  181. CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane(
  182. 300, CRect(0, 0,200, 120), xtpPaneDockLeft);
  183. pwndPane1->SetTitle(_T("Styles"));
  184. pwndPane1->SetOptions(xtpPaneNoHideable | xtpPaneHasMenuButton);
  185. m_paneStyles.Create(CPaneStyles::IDD, this);
  186. pwndPane1->Attach(&m_paneStyles);
  187. }
  188. BOOL CMainFrame::CreateMessageBar()
  189. {
  190. if (!m_wndMessageBar.Create(GetCommandBars()))
  191. return FALSE;
  192. m_wndMessageBar.AddButton(SC_CLOSE, NULL, _T("Close Message Bar"));
  193. m_wndMessageBar.AddButton(XTP_ID_CUSTOMIZE, _T("Options..."), _T("Show more options"));
  194. XTPImageManager()->SetIcon(IDC_MESSAGEBAR_WARNING, IDC_MESSAGEBAR_WARNING);
  195. //m_wndMessageBar.SetMessage(_T("Security Warning. Certain content has been disabled"));
  196. m_wndMessageBar.EnableMarkup();
  197. m_wndMessageBar.SetMessage(
  198. _T("<StackPanel Orientation='Horizontal'>")
  199. _T("        <Image Source='22988'/>")
  200. _T(" <TextBlock Padding='3, 0, 0, 0' VerticalAlignment='Center'><Bold>Security Warning</Bold></TextBlock>")
  201. _T(" <TextBlock Padding='10, 0, 0, 0' VerticalAlignment='Center'>Certain content has been disabled.</TextBlock>")
  202. _T("</StackPanel>"));
  203. return TRUE;
  204. }
  205. BOOL CMainFrame::CreateStatusBar()
  206. {
  207. if (!m_wndStatusBar.Create(this))
  208. {
  209. TRACE0("Failed to create status barn");
  210. return FALSE;      // fail to create
  211. }
  212. CXTPStatusBarPane* pPane;
  213. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_PAGENUMBER);
  214. pPane->SetButton();
  215. pPane->SetPadding(8, 0, 8, 0);
  216. pPane->SetBeginGroup(TRUE);
  217. pPane->SetCaption(_T("&Page Number"));
  218. pPane->SetValue(_T("1 of 1"));
  219. pPane->SetText(_T("Page: 1 of 1"));
  220. pPane->SetTooltip(_T("Page number in document"));
  221. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_WORDCOUNT);
  222. pPane->SetButton();
  223. pPane->SetPadding(8, 0, 8, 0);
  224. pPane->SetBeginGroup(TRUE);
  225. pPane->SetCaption(_T("&Word Count"));
  226. pPane->SetValue(_T("1"));
  227. pPane->SetText(_T("Words: 1"));
  228. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_LANGUAGE);
  229. pPane->SetButton();
  230. pPane->SetPadding(8, 0, 8, 0);
  231. pPane->SetBeginGroup(TRUE);
  232. pPane->SetCaption(_T("&Language"));
  233. pPane->SetValue(_T("English (U.S.)"));
  234. pPane->SetText(_T("English (U.S.)"));
  235. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_TRACKCHANGES);
  236. pPane->SetButton();
  237. pPane->SetPadding(8, 0, 8, 0);
  238. pPane->SetBeginGroup(TRUE);
  239. pPane->SetCaption(_T("&Track Changes"));
  240. pPane->SetValue(_T("Off"));
  241. pPane->SetText(_T("Track Changes: Off"));
  242. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_CAPSLOCK);
  243. pPane->SetPadding(8, 0, 8, 0);
  244. pPane->SetBeginGroup(TRUE);
  245. pPane->ShowBorders(FALSE);
  246. pPane->SetCaption(_T("&Caps Lock"));
  247. pPane->SetValue(_T("Off"));
  248. pPane->SetText(_T("Caps Lock"));
  249. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_OVERTYPE);
  250. pPane->SetButton();
  251. pPane->SetPadding(8, 0, 8, 0);
  252. pPane->SetBeginGroup(FALSE);
  253. pPane->SetCaption(_T("&Overtype"));
  254. pPane->SetValue(_T("Insert"));
  255. pPane->SetText(_T("Insert"));
  256. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_MACRORECORDING);
  257. pPane->SetButton();
  258. pPane->SetPadding(4, 0, 4, 0);
  259. pPane->SetIconIndex(ID_INDICATOR_MACRORECORDING);
  260. pPane->SetBeginGroup(FALSE);
  261. pPane->SetCaption(_T("&Macro Recording"));
  262. pPane->SetValue(_T("Not Recording"));
  263. UINT nID = ID_INDICATOR_MACRORECORDING;
  264. m_wndStatusBar.GetImageManager()->SetIcons(ID_INDICATOR_MACRORECORDING, &nID, 1, 0);
  265. CXTPStatusBarProgressPane* pProgressPane = (CXTPStatusBarProgressPane*)m_wndStatusBar.AddIndicator(new CXTPStatusBarProgressPane(), ID_INDICATOR_PROGRESS);
  266. pProgressPane->SetBeginGroup(FALSE);
  267. pProgressPane->SetCaption(_T("&ProgressBar"));
  268. pProgressPane->SetWidth(100);
  269. pProgressPane->SetPos(30);
  270. pProgressPane->SetPadding(3, 0, 3, 0);
  271. pProgressPane->SetVisible(FALSE);
  272. pPane = m_wndStatusBar.AddIndicator(0);
  273. pPane->SetWidth(1);
  274. pPane->SetStyle(SBPS_STRETCH | SBPS_NOBORDERS);
  275. pPane->SetBeginGroup(TRUE);
  276. static UINT switches[] =
  277. {
  278. ID_SWITCH_PRINTLAYOUT,
  279. ID_SWITCH_FULLSCREENREADING,
  280. ID_SWITCH_WEBLAYOUT,
  281. ID_SWITCH_OUTLINE,
  282. ID_SWITCH_DRAFT,
  283. };
  284. CXTPStatusBarSwitchPane* pSwitchPane = (CXTPStatusBarSwitchPane*)m_wndStatusBar.AddIndicator(new CXTPStatusBarSwitchPane(), ID_INDICATOR_VIEWSHORTCUTS);
  285. pSwitchPane->SetSwitches(switches, sizeof(switches)/sizeof(UINT));
  286. pSwitchPane->SetChecked(ID_SWITCH_PRINTLAYOUT);
  287. pSwitchPane->SetBeginGroup(TRUE);
  288. m_wndStatusBar.GetImageManager()->SetIcons(IDB_STATUSBAR_VIEWSWITCH, switches, sizeof(switches)/sizeof(UINT), 0);
  289. pSwitchPane->SetCaption(_T("&View Shortcuts"));
  290. pPane = m_wndStatusBar.AddIndicator(ID_INDICATOR_ZOOM);
  291. pPane->SetText(_T("100%"));
  292. pPane->SetButton();
  293. pPane->SetTextAlignment(DT_CENTER);
  294. pPane->SetPadding(8, 0, 8, 0);
  295. pPane->SetWidth(pPane->GetBestFit());
  296. pPane->SetTooltip(_T("Zoom level. Click to open the Zoom dialog box."));
  297. pPane->SetCaption(_T("&Zoom"));
  298. pPane->SetBeginGroup(FALSE);
  299. CXTPStatusBarSliderPane* pZoomPane = (CXTPStatusBarSliderPane*)m_wndStatusBar.AddIndicator(new CXTPStatusBarSliderPane(), ID_INDICATOR_ZOOMSLIDER);
  300. pZoomPane->SetBeginGroup(FALSE);
  301. pZoomPane->SetWidth(130);
  302. pZoomPane->SetPos(500); // We will convert 0 -> 10%, 500 -> 100 %, 1000 -> 500 %
  303. pZoomPane->SetRange(0, 1000);
  304. pZoomPane->SetCaption(_T("&Zoom Slider"));
  305. pZoomPane->SetTooltip(_T("Zoom"));
  306. pZoomPane->SetTooltipPart(XTP_HTSCROLLUP, _T("Zoom Out"));
  307. pZoomPane->SetTooltipPart(XTP_HTSCROLLDOWN, _T("Zoom In"));
  308. m_wndStatusBar.SetDrawDisabledText(FALSE);
  309. m_wndStatusBar.SetRibbonDividerIndex(pSwitchPane->GetIndex() - 1);
  310. m_wndStatusBar.EnableCustomization();
  311. CXTPToolTipContext* pToolTipContext = m_wndStatusBar.GetToolTipContext();
  312. pToolTipContext->SetStyle(xtpToolTipOffice2007);
  313. pToolTipContext->SetFont(m_wndStatusBar.GetPaintManager()->GetIconFont());
  314. return TRUE;
  315. }
  316. void CMainFrame::LoadIcons()
  317. {
  318. CXTPCommandBars* pCommandBars = GetCommandBars();
  319. pCommandBars->GetImageManager()->SetIcons(IDR_SMALLICONS);
  320. pCommandBars->GetImageManager()->SetIcons(IDR_LARGEICONS);
  321. pCommandBars->GetImageManager()->SetIcons(IDR_LAYOUTTABLARGE);
  322. pCommandBars->GetImageManager()->SetIcons(IDR_LAYOUTTABSMALL);
  323. UINT uiGroups[] = {ID_GROUP_CLIPBOARD, ID_GROUP_FONT, ID_GROUP_PARAGRAPH, ID_GROUP_FIND}; 
  324. pCommandBars->GetImageManager()->SetIcons(IDB_BITMAPS_GROUPS, uiGroups, _countof(uiGroups), CSize(16, 16));
  325. UINT uiSystemMenu[] = {ID_FILE_NEW, ID_FILE_OPEN, ID_FILE_SAVE, ID_FILE_SAVE_AS, ID_FILE_PRINT, ID_FILE_PRINT_SETUP, 
  326. ID_FILE_PRINT_PREVIEW, ID_FILE_PREPARE, ID_FILE_SEND, ID_APP_CLOSE, ID_FILE_SEND_MAIL, ID_FILE_SEND_INTERNETFAX}; 
  327. pCommandBars->GetImageManager()->SetIcons(IDB_SYSTEMMENULARGE, uiSystemMenu, _countof(uiSystemMenu), CSize(32, 32));
  328. UINT uiGroupParagraph[] = {ID_INSERT_BULLET, ID_INSERT_NUMBERING, ID_INSERT_LIST, 
  329. ID_PARA_DECREASEINDENT, ID_PARA_INCREASEINDENT, ID_PARA_SORT, ID_PARA_SHOWMARKS, ID_PARA_LEFT, 
  330. ID_PARA_CENTER, ID_PARA_RIGHT, ID_PARA_JUSTIFY, ID_PARA_LINESPACING, ID_PARA_SHADING, ID_BORDERS_NOBORDER};
  331. pCommandBars->GetImageManager()->SetIcons(ID_GROUP_PARAGRAPH, uiGroupParagraph, _countof(uiGroupParagraph), CSize(16, 16));
  332. UINT uiGroupClipboard[] = {ID_EDIT_PASTE, ID_EDIT_CUT, ID_EDIT_COPY, ID_FORMAT_PAINTER};
  333. pCommandBars->GetImageManager()->SetIcons(ID_GROUP_CLIPBOARD, uiGroupClipboard, _countof(uiGroupClipboard), CSize(16, 16));
  334. UINT uiGroupFont[] = {ID_FONT_GROW, ID_FONT_SHRINK, ID_FONT_CLEAR, ID_CHAR_BOLD, ID_CHAR_ITALIC, ID_CHAR_UNDERLINE,
  335. ID_CHAR_STRIKETHROUGH, ID_TEXT_SUBSCRIPT,ID_TEXT_SUPERSCRIPT, ID_TEXT_CHANGECASE, ID_TEXT_COLOR, ID_TEXT_HIGHLIGHTCOLOR};
  336. pCommandBars->GetImageManager()->SetIcons(ID_GROUP_FONT, uiGroupFont, _countof(uiGroupFont), CSize(16, 16));
  337. UINT uiGroupStyles[] = {ID_GALLERY_STYLES, ID_STYLES_CHANGE};
  338. pCommandBars->GetImageManager()->SetIcons(ID_GROUP_STYLES, uiGroupStyles, _countof(uiGroupStyles), CSize(32, 32));
  339. UINT uiGroupFind[] = {ID_EDIT_FIND, ID_EDIT_REPLACE, ID_EDIT_GOTO, ID_EDIT_SELECT};
  340. pCommandBars->GetImageManager()->SetIcons(ID_GROUP_FIND, uiGroupFind, _countof(uiGroupFind), CSize(16, 16));
  341. UINT uiInsertTabIcons[] = {ID_PAGES_NEW, ID_PAGES_COVER, ID_PAGES_BREAK, ID_INSERT_HEADER, ID_INSERT_FOOTER, ID_INSERT_PAGENUMBER, 
  342. ID_TEXT_PARTS, ID_TEXT_WORDART, ID_TEXT_DROPCAP, 
  343. ID_ILLUSTRATION_GRAPHIC, ID_ILLUSTRATION_CLIPART, ID_ILLUSTRATION_CLIPART, ID_ILLUSTRATION_CHART, 
  344. ID_INSERT_HYPERLINK, ID_INSERT_BOOKMARK, ID_INSERT_CROSS_REFERENCE, ID_TEXT_SIGNATURE, ID_TEXT_DATETIME, ID_TEXT_INSERTOBJECT};
  345. pCommandBars->GetImageManager()->SetIcons(IDB_INSERTTAB, uiInsertTabIcons, _countof(uiInsertTabIcons), CSize(16, 16));
  346. pCommandBars->GetImageManager()->SetIcon(ID_GROUP_BUTTONPOPUP, ID_GROUP_BUTTONPOPUP);
  347. UINT uiTabReferences[] = {ID_CONTENTS_TABLE, ID_FOOTNOTES_INSERT, 1, ID_CAPTIONS_INSERT, ID_INDEX_MARK };
  348. pCommandBars->GetImageManager()->SetIcons(ID_TAB_REFERENCES, uiTabReferences, _countof(uiTabReferences), CSize(32, 32));
  349. UINT uiView[] = {ID_VIEW_PRINTLAYOUT, ID_VIEW_FULLSCREENREADING, ID_VIEW_WEBLAYOUT, ID_VIEW_OUTLINE, ID_VIEW_DRAFT,
  350. ID_ZOOM_ZOOM, ID_WINDOW_NEW, ID_WINDOW_ARRANGE, ID_WINDOW_SPLIT, ID_WINDOW_SWITCH};
  351. pCommandBars->GetImageManager()->SetIcons(ID_TAB_VIEW, uiView, _countof(uiView), CSize(32, 32));
  352. UINT uiPageParagraph[] = {ID_PARAGRAPH_INDENTLEFT, ID_PARAGRAPH_INDENTRIGHT, ID_PARAGRAPH_SPACINGBEFORE, ID_PARAGRAPH_SPACINGAFTER};
  353. pCommandBars->GetImageManager()->SetIcons( ID_GROUP_PAGEPARAGRAPH, uiPageParagraph, _countof(uiPageParagraph), CSize(16, 16));
  354. UINT uiTabPageLayout[] = {ID_ARRANGE_POSITION, ID_ARRANGE_FRONT, ID_ARRANGE_BACK, ID_ARRANGE_TEXTWRAPPING,
  355. ID_ARRANGE_ALIGN, ID_ARRANGE_GROUP, ID_ARRANGE_ROTATE};
  356. pCommandBars->GetImageManager()->SetIcons(ID_TAB_PAGELAYOUT, uiTabPageLayout, _countof(uiTabPageLayout), CSize(32, 32));
  357. UINT uiGroupsTip[] = {ID_GROUP_CLIPBOARD_OPTION, ID_GROUP_FONT_OPTION, ID_GROUP_PARAGRAPH_OPTION, ID_GROUP_STYLES_OPTION, IDB_GEAR};
  358. pCommandBars->GetImageManager()->SetIcons(IDB_GROUPOPTIONTOOLTIP, uiGroupsTip, _countof(uiGroupsTip), CSize(100, 130));
  359. }
  360. void CMainFrame::CreateGalleries()
  361. {
  362. m_pItemsShapes = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_SHAPES);
  363. m_pItemsShapes->GetImageManager()->SetIcons(ID_GALLERY_SHAPES, 0, 0, CSize(20, 20));
  364. CXTPControlGalleryItem* pItem = m_pItemsShapes->AddLabel(0);
  365. pItem->SetCaption(_T("Lines"));
  366. int nShape;
  367. for (nShape = 0; nShape < 12; nShape++)
  368. m_pItemsShapes->AddItem(nShape, nShape);
  369. pItem = m_pItemsShapes->AddLabel(0);
  370. pItem->SetCaption(_T("Basic Shapes"));
  371. for (; nShape < 12 + 32; nShape++)
  372. m_pItemsShapes->AddItem(nShape, nShape);
  373. pItem = m_pItemsShapes->AddLabel(0);
  374. pItem->SetCaption(_T("Block Arrows"));
  375. for (; nShape < 12 + 32 + 27; nShape++)
  376. m_pItemsShapes->AddItem(nShape, nShape);
  377. pItem = m_pItemsShapes->AddLabel(0);
  378. pItem->SetCaption(_T("Flowchart"));
  379. for (; nShape < 12 + 32 + 27 + 28; nShape++)
  380. m_pItemsShapes->AddItem(nShape, nShape);
  381. pItem = m_pItemsShapes->AddLabel(0);
  382. pItem->SetCaption(_T("Callouts"));
  383. for (; nShape < 12 + 32 + 27 + 28 + 20; nShape++)
  384. m_pItemsShapes->AddItem(nShape, nShape);
  385. pItem = m_pItemsShapes->AddLabel(0);
  386. pItem->SetCaption(_T("Stars and Banners"));
  387. for (; nShape < 12 + 32 + 27 + 28 + 20 + 16; nShape++)
  388. m_pItemsShapes->AddItem(nShape, nShape);
  389. m_nShape = -1;
  390. m_nStyle = 0;
  391. m_pItemsStyles = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_STYLES);
  392. m_pItemsStyles->GetImageManager()->SetMaskColor(0xFF00FF);
  393. m_pItemsStyles->GetImageManager()->SetIcons(ID_GALLERY_STYLES, 0, 0, CSize(64, 48));
  394. m_pItemsStyles->GetImageManager()->SetMaskColor(COLORREF_NULL); // Default TopLeft Pixel.
  395. m_pItemsStyles->SetItemSize(CSize(72, 56));
  396. for (int nStyle = 0; nStyle < 16; nStyle++)
  397. m_pItemsStyles->AddItem(nStyle, nStyle);
  398. m_nStyleSet = 0;
  399. m_pItemsStyleSet = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_STYLESET);
  400. m_pItemsStyleSet->SetItemSize(CSize(0, 22));
  401. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(0, _T("Classic")));
  402. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(1, _T("Default")));
  403. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(2, _T("Distinctive")));
  404. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(3, _T("Elegant")));
  405. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(4, _T("Fancy")));
  406. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(5, _T("Formal")));
  407. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(6, _T("Manuscript")));
  408. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(7, _T("Modern")));
  409. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(8, _T("Simple")));
  410. m_pItemsStyleSet->AddItem(new CGalleryItemStyleSet(9, _T("Traditional")));
  411. m_nThemeColors = 0;
  412. m_pItemsThemeColors = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_COLORS);
  413. m_pItemsThemeColors->SetItemSize(CSize(0, 20));
  414. pItem = m_pItemsThemeColors->AddLabel(0);
  415. pItem->SetCaption(_T("Built-In"));
  416. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(0, _T("Office")));
  417. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(1, _T("Grayscale")));
  418. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(2, _T("Apex")));
  419. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(3, _T("Aspect")));
  420. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(4, _T("Civic")));
  421. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(5, _T("Concourse")));
  422. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(6, _T("Currency")));
  423. m_pItemsThemeColors->AddItem(new CGalleryItemThemeColors(7, _T("Deluxe")));
  424. m_nThemeFonts = 0;
  425. m_pItemsThemeFonts = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_FONTS);
  426. m_pItemsThemeFonts->SetItemSize(CSize(0, 60));
  427. pItem = m_pItemsThemeFonts->AddLabel(0);
  428. pItem->SetCaption(_T("Built-In"));
  429. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(0, _T("Office")));
  430. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(1, _T("Apex")));
  431. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(2, _T("Aspect")));
  432. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(3, _T("Civic")));
  433. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(4, _T("Concourse")));
  434. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(5, _T("Currency")));
  435. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(6, _T("Deluxe")));
  436. m_pItemsThemeFonts->AddItem(new CGalleryItemThemeFonts(7, _T("Equity")));
  437. m_pItemsFontTextColor = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_FONTTEXTCOLOR);
  438. m_pItemsFontTextColor->SetItemSize(CSize(17, 17));
  439. pItem = m_pItemsFontTextColor->AddLabel(0);
  440. pItem->SetCaption(_T("Theme Colors"));
  441. CGalleryItemFontColor::AddThemeColors(m_pItemsFontTextColor, 0);
  442. pItem = m_pItemsFontTextColor->AddLabel(0);
  443. pItem->SetCaption(_T("Standard Colors"));
  444. CGalleryItemFontColor::AddStandardColors(m_pItemsFontTextColor);
  445. m_pItemsFontBackColor = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_FONTBACKCOLOR);
  446. m_pItemsFontBackColor->SetItemSize(CSize(30, 30));
  447. CGalleryItemFontColor::AddStandardBackColors(m_pItemsFontBackColor);
  448. m_pItemsFontFace = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_FONTFACE);
  449. m_pItemsFontFace->SetItemSize(CSize(0, 26));
  450. CGalleryItemFontFace::AddFontItems(m_pItemsFontFace);
  451. m_pItemsFontSize = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_FONTSIZE);
  452. m_pItemsFontSize->SetItemSize(CSize(0, 17));
  453. m_pItemsFontSize->AddItem(_T("8"));
  454. m_pItemsFontSize->AddItem(_T("9"));
  455. m_pItemsFontSize->AddItem(_T("10"));
  456. m_pItemsFontSize->AddItem(_T("11"));
  457. m_pItemsFontSize->AddItem(_T("12"));
  458. m_pItemsFontSize->AddItem(_T("14"));
  459. m_pItemsFontSize->AddItem(_T("16"));
  460. m_pItemsFontSize->AddItem(_T("18"));
  461. m_pItemsFontSize->AddItem(_T("20"));
  462. m_pItemsFontSize->AddItem(_T("22"));
  463. m_pItemsFontSize->AddItem(_T("24"));
  464. m_pItemsFontSize->AddItem(_T("26"));
  465. m_pItemsFontSize->AddItem(_T("28"));
  466. m_pItemsFontSize->AddItem(_T("36"));
  467. m_pItemsFontSize->AddItem(_T("48"));
  468. m_pItemsFontSize->AddItem(_T("72"));
  469. m_pItemsUndo = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_EDIT_UNDO);
  470. m_pItemsUndo->SetItemSize(CSize(0, 21));
  471. m_pItemsUndo->ClipItems(FALSE);
  472. m_pItemsColumns = CXTPControlGalleryItems::CreateItems(GetCommandBars(), ID_GALLERY_COLUMNS);
  473. m_pItemsColumns->GetImageManager()->SetIcons(ID_GALLERY_COLUMNS, 0, 0, CSize(32, 32));
  474. m_pItemsColumns->AddItem(_T("One"), 0, 0);
  475. m_pItemsColumns->AddItem(_T("Two"), 1, 1);
  476. m_pItemsColumns->AddItem(_T("Three"), 2, 2);
  477. m_pItemsColumns->AddItem(_T("Left"), 3, 3);
  478. m_pItemsColumns->AddItem(_T("Right"), 4, 4);
  479. m_pItemsColumns->SetItemSize(CSize(0, 44));
  480. }
  481. BOOL CMainFrame::CreateMiniToolBar()
  482. {
  483. CXTPCommandBars* pCommandBars = GetCommandBars();
  484. CXTPMiniToolBar* pMiniToolBar = CXTPMiniToolBar::CreateMiniToolBar(pCommandBars);
  485. pMiniToolBar->SetBarID(IDR_MENU_MINITOOLBAR);
  486. pMiniToolBar->SetTitle(_T("MiniBar"));
  487. CXTPControlComboBox* pComboFont = new CXTPControlComboBox();
  488. pMiniToolBar->GetControls()->Add(pComboFont, ID_FONT_FACE);
  489. pComboFont->SetDropDownListStyle();
  490. pComboFont->EnableAutoComplete();
  491. pComboFont->SetWidth(64);
  492. CXTPPopupBar* pPopupBarGallery = CXTPControlComboBoxGalleryPopupBar::CreateComboBoxGalleryPopupBar(pCommandBars);
  493. pComboFont->SetCommandBar(pPopupBarGallery);
  494. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  495. pControlGallery->SetControlSize(CSize(290, 508));
  496. pControlGallery->SetResizable(FALSE, TRUE);
  497. pControlGallery->ShowLabels(TRUE);
  498. pControlGallery->SetItems(m_pItemsFontFace);
  499. pPopupBarGallery->GetControls()->Add(pControlGallery, ID_GALLERY_FONTFACE);
  500. pPopupBarGallery->InternalRelease();
  501. pComboFont = new CXTPControlComboBox();
  502. pMiniToolBar->GetControls()->Add(pComboFont, ID_FONT_SIZE);
  503. pComboFont->SetDropDownListStyle();
  504. pComboFont->SetWidth(45);
  505. pPopupBarGallery = CXTPControlComboBoxGalleryPopupBar::CreateComboBoxGalleryPopupBar(pCommandBars);
  506. pComboFont->SetCommandBar(pPopupBarGallery);
  507. pControlGallery = new CXTPControlGallery();
  508. pControlGallery->SetControlSize(CSize(42, 16 * 17));
  509. pControlGallery->SetResizable(FALSE, TRUE);
  510. pControlGallery->SetItems(m_pItemsFontSize);
  511. pPopupBarGallery->GetControls()->Add(pControlGallery, ID_GALLERY_FONTSIZE);
  512. pPopupBarGallery->InternalRelease();
  513. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_FONT_GROW);
  514. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_FONT_SHRINK);
  515. pMiniToolBar->GetControls()->Add(xtpControlButtonPopup, ID_STYLES_CHANGE);
  516. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_CHAR_BOLD);
  517. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_CHAR_ITALIC);
  518. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_PARA_LEFT);
  519. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_PARA_CENTER);
  520. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_PARA_RIGHT);
  521. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_PARA_INCREASEINDENT);
  522. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_PARA_DECREASEINDENT);
  523. pMiniToolBar->GetControls()->Add(xtpControlButton, ID_INSERT_BULLET);
  524. pCommandBars->GetContextMenus()->Add(pMiniToolBar);
  525. pMiniToolBar->SetWidth(22 * 8 + 4);
  526. // Add Simple context menu
  527. CMenu mnu;
  528. mnu.LoadMenu(IDR_MENU_CONTEXT);
  529. pCommandBars->GetContextMenus()->Add(IDR_MENU_CONTEXT, _T("Context Menu"), mnu.GetSubMenu(0));
  530. return TRUE;
  531. }
  532. BOOL CMainFrame::CreateRibbonBar()
  533. {
  534. CXTPCommandBars* pCommandBars = GetCommandBars();
  535. CMenu menu;
  536. menu.Attach(::GetMenu(m_hWnd));
  537. SetMenu(NULL);
  538. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T("The Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar));
  539. if (!pRibbonBar)
  540. {
  541. return FALSE;
  542. }
  543. pRibbonBar->EnableDocking(0);
  544. //pRibbonBar->GetTabPaintManager()->m_bSelectOnButtonDown = FALSE;
  545. CXTPControlPopup* pControlFile = (CXTPControlPopup*)pRibbonBar->AddSystemButton(ID_MENU_FILE);
  546. pControlFile->SetCommandBar(menu.GetSubMenu(0));
  547. pControlFile->GetCommandBar()->SetIconSize(CSize(32, 32));
  548. pControlFile->SetIconId(IDB_GEAR);
  549. UINT uCommand = {IDB_GEAR};
  550. pCommandBars->GetImageManager()->SetIcons(IDB_GEAR, &uCommand, 1, CSize(0, 0), xtpImageNormal);
  551. CXTPRibbonTab* pTabHome = pRibbonBar->AddTab(ID_TAB_HOME);
  552. CXTPRibbonGroup* pGroupClipborad = pTabHome->AddGroup(ID_GROUP_CLIPBOARD);
  553. pGroupClipborad->ShowOptionButton();
  554. pGroupClipborad->SetIconId(ID_GROUP_BUTTONPOPUP);
  555. pGroupClipborad->GetControlGroupOption()->SetID(ID_GROUP_CLIPBOARD_OPTION);
  556. pGroupClipborad->SetControlsCentering();
  557. CXTPControlPopup* pControlPaste = (CXTPControlPopup*)pGroupClipborad->Add(xtpControlSplitButtonPopup, ID_EDIT_PASTE);
  558. pControlPaste->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_PASTE);
  559. pControlPaste->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_PASTE_SPECIAL);
  560. CXTPControl* pControlCut = pGroupClipborad->Add(xtpControlButton, ID_EDIT_CUT);
  561. pControlCut->SetKeyboardTip(_T("X"));
  562. pGroupClipborad->Add(xtpControlButton, ID_EDIT_COPY);
  563. pGroupClipborad->Add(xtpControlButton, ID_FORMAT_PAINTER);
  564. pControlPaste->SetKeyboardTip(_T("V"));
  565. CXTPRibbonGroup* pGroupFont = pTabHome->AddGroup(ID_GROUP_FONT);
  566. pGroupFont->SetControlsGrouping();
  567. pGroupFont->ShowOptionButton();
  568. pGroupFont->GetControlGroupOption()->SetID(ID_GROUP_FONT_OPTION);
  569. CXTPControlComboBox* pComboFont = new CXTPControlComboBox();
  570. pGroupFont->Add(pComboFont, ID_FONT_FACE);
  571. pComboFont->SetDropDownListStyle();
  572. pComboFont->EnableAutoComplete();
  573. pComboFont->SetWidth(130);
  574. CXTPPopupBar* pPopupBarGallery = CXTPControlComboBoxGalleryPopupBar::CreateComboBoxGalleryPopupBar(pCommandBars);
  575. pComboFont->SetCommandBar(pPopupBarGallery);
  576. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  577. pControlGallery->SetControlSize(CSize(290, 508));
  578. pControlGallery->SetResizable(FALSE, TRUE);
  579. pControlGallery->ShowLabels(TRUE);
  580. pControlGallery->SetItems(m_pItemsFontFace);
  581. pPopupBarGallery->GetControls()->Add(pControlGallery, ID_GALLERY_FONTFACE);
  582. pPopupBarGallery->InternalRelease();
  583. pComboFont = new CXTPControlComboBox();
  584. pGroupFont->Add(pComboFont, ID_FONT_SIZE);
  585. pComboFont->SetDropDownListStyle();
  586. pComboFont->SetWidth(45);
  587. pPopupBarGallery = CXTPControlComboBoxGalleryPopupBar::CreateComboBoxGalleryPopupBar(pCommandBars);
  588. pComboFont->SetCommandBar(pPopupBarGallery);
  589. pControlGallery = new CXTPControlGallery();
  590. pControlGallery->SetControlSize(CSize(42, 16 * 17));
  591. pControlGallery->SetResizable(FALSE, TRUE);
  592. pControlGallery->SetItems(m_pItemsFontSize);
  593. pPopupBarGallery->GetControls()->Add(pControlGallery, ID_GALLERY_FONTSIZE);
  594. pPopupBarGallery->InternalRelease();
  595. CXTPControl* pControl = pGroupFont->Add(xtpControlButton, ID_FONT_GROW);
  596. pControl->SetBeginGroup(TRUE);
  597. pGroupFont->Add(xtpControlButton, ID_FONT_SHRINK);
  598. pControl = pGroupFont->Add(xtpControlButton, ID_FONT_CLEAR);
  599. pControl->SetBeginGroup(TRUE);
  600. pGroupFont->Add(xtpControlButton, ID_CHAR_BOLD)->SetBeginGroup(TRUE);
  601. pGroupFont->Add(xtpControlButton, ID_CHAR_ITALIC);
  602. pGroupFont->Add(xtpControlSplitButtonPopup, ID_CHAR_UNDERLINE);
  603. pGroupFont->Add(xtpControlButton, ID_CHAR_STRIKETHROUGH);
  604. pGroupFont->Add(xtpControlButton, ID_TEXT_SUBSCRIPT)->SetBeginGroup(TRUE);
  605. pGroupFont->Add(xtpControlButton, ID_TEXT_SUPERSCRIPT);
  606. pControl = pGroupFont->Add(xtpControlPopup, ID_TEXT_CHANGECASE);
  607. pControl->SetStyle(xtpButtonIcon);
  608. CXTPControlPopupColor* pPopupColor = (CXTPControlPopupColor*)pGroupFont->Add(new CXTPControlPopupColor(), ID_TEXT_HIGHLIGHTCOLOR);
  609. pPopupColor->SetBeginGroup(TRUE);
  610. CXTPPopupBar* pColorBar = CXTPPopupBar::CreatePopupBar(GetCommandBars());
  611. CMenu menuColor;
  612. menuColor.LoadMenu(ID_TEXT_HIGHLIGHTCOLOR);
  613. pColorBar->LoadMenu(menuColor.GetSubMenu(0));
  614. pPopupColor->SetCommandBar(pColorBar);
  615. pColorBar->InternalRelease();
  616. pPopupColor = (CXTPControlPopupColor*)pGroupFont->Add(new CXTPControlPopupColor, ID_TEXT_COLOR);
  617. pColorBar = CXTPPopupBar::CreatePopupBar(GetCommandBars());
  618. pColorBar->GetControls()->Add(new CXTPControlButton(), XTP_IDS_AUTOMATIC);
  619. pControlGallery = new CXTPControlGallery();
  620. pControlGallery->SetControlSize(CSize(171, 145));
  621. pControlGallery->ShowLabels(TRUE);
  622. pControlGallery->ShowScrollBar(FALSE);
  623. pControlGallery->SetItems(m_pItemsFontTextColor);
  624. pColorBar->GetControls()->Add(pControlGallery, ID_GALLERY_FONTTEXTCOLOR);
  625. pColorBar->GetControls()->Add(new CXTPControlButton(), XTP_IDS_MORE_COLORS);
  626. pPopupColor->SetCommandBar(pColorBar);
  627. pColorBar->EnableCustomization(FALSE);
  628. pColorBar->InternalRelease();
  629. CXTPRibbonGroup* pGroupParagraph = pTabHome->AddGroup(ID_GROUP_PARAGRAPH);
  630. pGroupParagraph->SetControlsGrouping();
  631. pGroupParagraph->ShowOptionButton();
  632. pGroupParagraph->GetControlGroupOption()->SetID(ID_GROUP_PARAGRAPH_OPTION);
  633. pGroupParagraph->Add(xtpControlSplitButtonPopup, ID_INSERT_BULLET);
  634. pGroupParagraph->Add(xtpControlSplitButtonPopup, ID_INSERT_NUMBERING);
  635. pGroupParagraph->Add(xtpControlSplitButtonPopup, ID_INSERT_LIST);
  636. pGroupParagraph->Add(xtpControlButton, ID_PARA_DECREASEINDENT)->SetBeginGroup(TRUE);
  637. pGroupParagraph->Add(xtpControlButton, ID_PARA_INCREASEINDENT);
  638. pGroupParagraph->Add(xtpControlButton, ID_PARA_SORT)->SetBeginGroup(TRUE);
  639. pGroupParagraph->Add(xtpControlButton, ID_PARA_SHOWMARKS)->SetBeginGroup(TRUE);
  640. pGroupParagraph->Add(xtpControlButton, ID_PARA_LEFT)->SetBeginGroup(TRUE);
  641. pGroupParagraph->Add(xtpControlButton, ID_PARA_CENTER);
  642. pGroupParagraph->Add(xtpControlButton, ID_PARA_RIGHT);
  643. pGroupParagraph->Add(xtpControlButton, ID_PARA_JUSTIFY);
  644. pGroupParagraph->Add(xtpControlButtonPopup, ID_PARA_LINESPACING)->SetBeginGroup(TRUE);
  645. pGroupParagraph->Add(xtpControlSplitButtonPopup, ID_PARA_SHADING)->SetBeginGroup(TRUE);
  646. pGroupParagraph->Add(xtpControlSplitButtonPopup, ID_BORDERS_NOBORDER)->SetBeginGroup(TRUE);
  647. CXTPRibbonGroup* pGroupStyles = pTabHome->AddGroup(ID_GROUP_STYLES);
  648. pGroupStyles->SetControlsCentering(TRUE);
  649. pControlGallery = (CXTPControlGallery*)pGroupStyles->Add(new CXTPControlGallery(), ID_GALLERY_STYLES);
  650. pControlGallery->SetControlSize(CSize(234, 60));
  651. pControlGallery->SetResizable();
  652. pControlGallery->SetItemsMargin(0, 1, 0, 1);
  653. pControlGallery->ShowLabels(FALSE);
  654. pControlGallery->ShowBorders(TRUE);
  655. pControlGallery->SetItems(m_pItemsStyles);
  656. CMenu menuQuickStyles;
  657. menuQuickStyles.LoadMenu(ID_STYLES_QUICKSTYLES);
  658. CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(GetCommandBars());
  659. pPopupBar->LoadMenu(menuQuickStyles.GetSubMenu(0));
  660. pControlGallery->SetCommandBar(pPopupBar);
  661. pPopupBar->EnableAnimation();
  662. pPopupBar->InternalRelease();
  663. pGroupStyles->Add(xtpControlButtonPopup, ID_STYLES_CHANGE);
  664. CXTPRibbonGroup* pGroupFind = pTabHome->AddGroup(ID_GROUP_FIND);
  665. CXTPControlPopup* pControlFind = (CXTPControlPopup*)pGroupFind->Add(xtpControlSplitButtonPopup, ID_EDIT_FIND);
  666. pControlFind->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_FIND);
  667. pControlFind->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_GOTO);
  668. pGroupFind->Add(xtpControlButton, ID_EDIT_REPLACE);
  669. CXTPControlPopup* pControlSelect = (CXTPControlPopup*)pGroupFind->Add(xtpControlPopup, ID_EDIT_SELECT);
  670. pGroupFind->SetIconId(ID_GROUP_BUTTONPOPUP);
  671. pControlSelect->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_SELECT_ALL);
  672. pControlSelect->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_SELECT_OBJECTS);
  673. pControlSelect->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_SELECT_MULTIPLE_OBJECTS);
  674. pControlSelect->SetFlags(xtpFlagManualUpdate);
  675. CXTPRibbonTab* pTabInsert = pRibbonBar->AddTab(ID_TAB_INSERT);
  676. CXTPRibbonGroup* pGroupShapes = pTabInsert->AddGroup(ID_GROUP_SHAPES);
  677. pControlGallery = (CXTPControlGallery*)pGroupShapes->Add(
  678. new CXTPControlGallery(), ID_GALLERY_SHAPES);
  679. pControlGallery->SetControlSize(CSize(138, 60));
  680. pControlGallery->SetResizable();
  681. pControlGallery->ShowBorders(TRUE);
  682. pControlGallery->SetItemsMargin(0, -1, 0, -1);
  683. pControlGallery->ShowLabels(FALSE);
  684. pControlGallery->SetItems(m_pItemsShapes);
  685. CMenu menuShapes;
  686. menuShapes.LoadMenu(ID_INSERT_SHAPES);
  687. pPopupBar = CXTPPopupBar::CreatePopupBar(GetCommandBars());
  688. pPopupBar->LoadMenu(menuShapes.GetSubMenu(0));
  689. pControlGallery->SetCommandBar(pPopupBar);
  690. pPopupBar->EnableAnimation();
  691. pPopupBar->InternalRelease();
  692. CXTPRibbonGroup* pGroupPages = pTabInsert->AddGroup(ID_GROUP_PAGES);
  693. pGroupPages->SetIconId(ID_GROUP_BUTTONPOPUP);
  694. pGroupPages->Add(xtpControlSplitButtonPopup, ID_PAGES_NEW);
  695. pGroupPages->Add(xtpControlSplitButtonPopup, ID_PAGES_COVER);
  696. pGroupPages->Add(xtpControlButton, ID_PAGES_BREAK);
  697. pGroupPages->ShowOptionButton();
  698. CXTPRibbonGroup* pGroupTable = pTabInsert->AddGroup(ID_GROUP_TABLE);
  699. pGroupTable->Add(xtpControlButtonPopup, ID_TABLE_NEW);
  700. CXTPRibbonGroup* pGroupIllustrations = pTabInsert->AddGroup(ID_GROUP_ILLUSTRATIONS);
  701. pGroupIllustrations->Add(xtpControlSplitButtonPopup, ID_ILLUSTRATION_PICTURE);
  702. pGroupIllustrations->Add(xtpControlButton, ID_ILLUSTRATION_GRAPHIC);
  703. pGroupIllustrations->Add(xtpControlButton, ID_ILLUSTRATION_CHART);
  704. CXTPRibbonGroup* pGroupLinks = pTabInsert->AddGroup(ID_GROUP_LINKS);
  705. pGroupLinks->Add(xtpControlButton, ID_INSERT_HYPERLINK);
  706. pGroupLinks->Add(xtpControlButton, ID_INSERT_BOOKMARK);
  707. pGroupLinks->Add(xtpControlButton, ID_INSERT_CROSS_REFERENCE);
  708. CXTPRibbonGroup* pGroupHeader = pTabInsert->AddGroup(ID_GROUP_HEADERFOOTERS);
  709. pGroupHeader->Add(xtpControlButtonPopup, ID_INSERT_HEADER);
  710. pGroupHeader->Add(xtpControlButtonPopup, ID_INSERT_FOOTER);
  711. pGroupHeader->Add(xtpControlButtonPopup, ID_INSERT_PAGENUMBER);
  712. CXTPRibbonGroup* pGroupText = pTabInsert->AddGroup(ID_GROUP_TEXT);
  713. pGroupText->Add(xtpControlButtonPopup, ID_TEXT_TEXTBOX);
  714. pGroupText->Add(xtpControlSplitButtonPopup, ID_TEXT_PARTS);
  715. pGroupText->Add(xtpControlButtonPopup, ID_TEXT_WORDART);
  716. pGroupText->Add(xtpControlButtonPopup, ID_TEXT_DROPCAP);
  717. pGroupText->Add(xtpControlSplitButtonPopup, ID_TEXT_SIGNATURE);
  718. pGroupText->Add(xtpControlButton, ID_TEXT_DATETIME);
  719. pGroupText->Add(xtpControlSplitButtonPopup, ID_TEXT_INSERTOBJECT);
  720. CXTPRibbonGroup* pGroupSymbols = pTabInsert->AddGroup(ID_GROUP_SYMBOLS);
  721. pGroupSymbols->Add(xtpControlButtonPopup, ID_SYMBOL_EQUATIONS);
  722. pGroupSymbols->Add(xtpControlButtonPopup, ID_SYMBOL_SYMBOL);
  723. pGroupSymbols->GetControlGroupPopup()->SetIconId(ID_SYMBOL_SYMBOL);
  724. CXTPRibbonTab* pTabPageLayout = pRibbonBar->AddTab(ID_TAB_PAGELAYOUT);
  725. CXTPRibbonGroup* pGroupThemes = pTabPageLayout->AddGroup(ID_GROUP_THEMES);
  726. pGroupThemes->SetIconId(ID_GROUP_BUTTONPOPUP);
  727. pGroupThemes->Add(xtpControlSplitButtonPopup, ID_THEMES_THEMES);
  728. pGroupThemes->Add(xtpControlPopup, ID_THEMES_COLORS);
  729. pGroupThemes->Add(xtpControlPopup, ID_THEMES_FONTS);
  730. CXTPControlPopup* pControlPopup = (CXTPControlPopup*)pGroupThemes->Add(xtpControlPopup, ID_THEMES_EFFECTS);
  731. pControlPopup->GetCommandBar()->GetControls()->Add(new CXTPControlLabel(), ID_THEMES_BUILTIN);
  732. pControlPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_THEMES_OFFICE);
  733. CXTPRibbonGroup* pGroupPageSetup = pTabPageLayout->AddGroup(ID_GROUP_PAGESETUP);
  734. pGroupThemes->SetIconId(ID_GROUP_BUTTONPOPUP);
  735. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_MARGINS);
  736. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_ORIENTATION);
  737. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_SIZE);
  738. pControlPopup = (CXTPControlPopup*)pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_COLUMNS);
  739. pControlGallery = (CXTPControlGallery*)pControlPopup->GetCommandBar()->GetControls()->Add(new CXTPControlGallery(), ID_GALLERY_COLUMNS);
  740. pControlGallery->SetControlSize(CSize(140, 44 * 5));
  741. pControlGallery->ShowScrollBar(FALSE);
  742. pControlGallery->SetItems(m_pItemsColumns);
  743. pControlGallery->SetStyle(xtpButtonIconAndCaption);
  744. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_BREAKS);
  745. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_LINENUMBERS);
  746. pGroupPageSetup->Add(xtpControlPopup, ID_PAGE_HYPHENATATION);
  747. CXTPRibbonGroup* pGroupPageBackground = pTabPageLayout->AddGroup(ID_GROUP_PAGEBACKGROUND);
  748. pGroupPageBackground->Add(xtpControlPopup, ID_PAGE_WATERMARK);
  749. pGroupPageBackground->Add(xtpControlPopup, ID_PAGE_COLOR);
  750. pGroupPageBackground->Add(xtpControlButton, ID_PAGE_BORDERS);
  751. CXTPRibbonGroup* pGroupPageParagraph = pTabPageLayout->AddGroup(ID_GROUP_PAGEPARAGRAPH);
  752. pControl = pGroupPageParagraph->Add(xtpControlLabel, ID_PARAGRAPH_INDENT);
  753. pControl->SetID(0);
  754. pControl->SetStyle(xtpButtonCaption);
  755. CXTPControlEdit* pControlEdit = (CXTPControlEdit*)pGroupPageParagraph->Add(xtpControlEdit, ID_PARAGRAPH_INDENTLEFT);
  756. pControlEdit->SetWidth(133);
  757. pControlEdit->ShowSpinButtons();
  758. pControlEdit = (CXTPControlEdit*)pGroupPageParagraph->Add(xtpControlEdit, ID_PARAGRAPH_INDENTRIGHT);
  759. pControlEdit->SetWidth(133);
  760. pControlEdit->ShowSpinButtons();
  761. pControl = pGroupPageParagraph->Add(xtpControlLabel, ID_PARAGRAPH_SPACING);
  762. pControl->SetBeginGroup(TRUE);
  763. pControl->SetID(0);
  764. pControl->SetStyle(xtpButtonCaption);
  765. pControlEdit = (CXTPControlEdit*)pGroupPageParagraph->Add(xtpControlEdit, ID_PARAGRAPH_SPACINGBEFORE);
  766. pControlEdit->SetWidth(133);
  767. pControlEdit->ShowSpinButtons();
  768. pControlEdit = (CXTPControlEdit*)pGroupPageParagraph->Add(xtpControlEdit, ID_PARAGRAPH_SPACINGAFTER);
  769. pControlEdit->SetWidth(133);
  770. pControlEdit->ShowSpinButtons();
  771. CXTPRibbonGroup* pGroupArrange = pTabPageLayout->AddGroup(ID_GROUP_ARRANGE);
  772. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_POSITION);
  773. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_FRONT);
  774. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_BACK);
  775. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_TEXTWRAPPING);
  776. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_ALIGN);
  777. pControlPopup = (CXTPControlPopup*)pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_GROUP);
  778. pControlPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_ARRANGE_GROUP);
  779. pControlPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_ARRANGE_UNGROUP);
  780. pGroupArrange->Add(xtpControlPopup, ID_ARRANGE_ROTATE);
  781. CXTPRibbonTab* pTabReferences = pRibbonBar->AddTab(ID_TAB_REFERENCES);
  782. pTabReferences->AddGroup(ID_GROUP_TABLEOFCONTENTS);
  783. pTabReferences->AddGroup(ID_GROUP_FOOTNOTES);
  784. pTabReferences->AddGroup(ID_GROUP_CAPTIONS);
  785. pTabReferences->AddGroup(ID_GROUP_INDEX);
  786. CXTPRibbonTab* pTab;
  787. pTab = pRibbonBar->AddTab(ID_TAB_MAILINGS);
  788. pTab = pRibbonBar->AddTab(ID_TAB_REVIEW);
  789. pTab->SetContextTab(xtpRibbonTabContextColorPurple);
  790. CXTPRibbonTab* pTabView = pRibbonBar->AddTab(ID_TAB_VIEW);
  791. pTabView->AddGroup(ID_GROUP_DOCUMENTVIEWS);
  792. CXTPRibbonGroup* pGroupShowHide = pTabView->AddGroup(ID_GROUP_SHOWHIDE);
  793. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_RULER);
  794. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_GRIDLINES);
  795. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_PROPERTIES);
  796. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_DOCUMENTMAP);
  797. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_STATUS_BAR);
  798. pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_MESSAGE_BAR);
  799. pTabView->AddGroup(ID_GROUP_ZOOM);
  800. pTabView->AddGroup(ID_GROUP_WINDOW);
  801. pTab = pRibbonBar->AddTab(ID_TAB_TABLEDESIGN);
  802. pTab->SetContextTab(xtpRibbonTabContextColorYellow, _T("Table Tools"));
  803. pTab = pRibbonBar->AddTab(ID_TAB_TABLELAYOUT);
  804. pTab->SetContextTab(xtpRibbonTabContextColorYellow, _T("Table Tools"));
  805. pTab = pRibbonBar->AddTab(ID_TAB_CHARTDESIGN);
  806. pTab->SetContextTab(xtpRibbonTabContextColorGreen, ID_TAB_CONTEXTCHART);
  807. pTab = pRibbonBar->AddTab(ID_TAB_CHARTLAYOUT);
  808. pTab->SetContextTab(xtpRibbonTabContextColorGreen, ID_TAB_CONTEXTCHART);
  809. pTab = pRibbonBar->AddTab(ID_TAB_CHARTFORMAT);
  810. pTab->SetContextTab(xtpRibbonTabContextColorGreen, ID_TAB_CONTEXTCHART);
  811. pTab = pRibbonBar->AddTab(ID_TAB_PICTUREFORMAT);
  812. pTab->SetContextTab(xtpRibbonTabContextColorRed, _T("Picture Tools"));
  813. CXTPControlPopup* pControlOptions = (CXTPControlPopup*)pRibbonBar->GetControls()->Add(xtpControlPopup, -1);
  814. pControlOptions->SetFlags(xtpFlagRightAlign);
  815. CMenu mnuOptions;
  816. mnuOptions.LoadMenu(IDR_MENU_OPTIONS);
  817. pControlOptions->SetCommandBar(mnuOptions.GetSubMenu(0));
  818. pControlOptions->SetCaption(_T("Options"));
  819. CXTPControl* pControlAbout = pRibbonBar->GetControls()->Add(xtpControlButton, ID_APP_ABOUT);
  820. pControlAbout->SetFlags(xtpFlagRightAlign);
  821. pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_NEW)->SetHideFlag(xtpHideCustomize, TRUE);
  822. pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_OPEN)->SetHideFlag(xtpHideCustomize, TRUE);
  823. pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_SAVE);
  824. CXTPControlPopup* pControlUndo = (CXTPControlPopup*)pRibbonBar->GetQuickAccessControls()->Add(xtpControlSplitButtonPopup, ID_EDIT_UNDO);
  825. pPopupBar = CXTPPopupBar::CreatePopupBar(GetCommandBars());
  826. pPopupBar->SetShowGripper(FALSE);
  827. pControlUndo->SetCommandBar(pPopupBar);
  828. pControlGallery = new CControlGalleryUndo();
  829. pControlGallery->SetItems(m_pItemsUndo);
  830. pControlGallery->SetWidth(120);
  831. pControlGallery->ShowScrollBar(FALSE);
  832. pPopupBar->GetControls()->Add(pControlGallery, ID_EDIT_UNDO);
  833. CXTPControlStatic* pControlListBoxInfo = (CXTPControlStatic*)pPopupBar->GetControls()->Add(new CXTPControlStatic(), ID_EDIT_UNDO);
  834. pControlListBoxInfo->SetWidth(120);
  835. pControlListBoxInfo->SetFlags(xtpFlagSkipFocus);
  836. pPopupBar->InternalRelease();
  837. pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_PRINT);
  838. pRibbonBar->GetQuickAccessControls()->CreateOriginalControls();
  839. pRibbonBar->SetCloseable(FALSE);
  840. pRibbonBar->EnableFrameTheme();
  841. return TRUE;
  842. }
  843. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  844. {
  845. if( !CXTPFrameWnd::PreCreateWindow(cs) )
  846. return FALSE;
  847. cs.lpszClass = _T("XTPMainFrame");
  848. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  849. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  850. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  851. return TRUE;
  852. }
  853. /////////////////////////////////////////////////////////////////////////////
  854. // CMainFrame diagnostics
  855. #ifdef _DEBUG
  856. void CMainFrame::AssertValid() const
  857. {
  858. CXTPFrameWnd::AssertValid();
  859. }
  860. void CMainFrame::Dump(CDumpContext& dc) const
  861. {
  862. CXTPFrameWnd::Dump(dc);
  863. }
  864. #endif //_DEBUG
  865. /////////////////////////////////////////////////////////////////////////////
  866. // CMainFrame message handlers
  867. void CMainFrame::OnEmptyCommandRange(UINT)
  868. {
  869. }
  870. void CMainFrame::OnEmptyCommand()
  871. {
  872. }
  873. void CMainFrame::OnSwitchCommand()
  874. {
  875. m_bChecked = !m_bChecked;
  876. }
  877. void CMainFrame::OnUpdateSwitchCommand(CCmdUI* pCmdUI)
  878. {
  879. pCmdUI->SetCheck(m_bChecked);
  880. }
  881. void CMainFrame::OnViewShowHide(UINT nID)
  882. {
  883. m_bOptions[nID - ID_VIEW_RULER] ^= 1;
  884. }
  885. void CMainFrame::OnUpdateViewShowHide(CCmdUI* pCmdUI)
  886. {
  887. pCmdUI->SetCheck(m_bOptions[pCmdUI->m_nID - ID_VIEW_RULER] ? TRUE : FALSE);
  888. }
  889. void CMainFrame::OnRibbonTabChanged(NMHDR* pNMHDR, LRESULT* pRes) 
  890. {
  891. NMXTPTABCHANGE* pNMTabChanged = (NMXTPTABCHANGE*)pNMHDR;
  892. if (pNMTabChanged->pTab)
  893. {
  894. TRACE(_T("Tab Changed, Caption = %sn"), (LPCTSTR)pNMTabChanged->pTab->GetCaption());
  895. }
  896. *pRes = 0;
  897. }
  898. void CMainFrame::OnRibbonTabChanging(NMHDR* /*pNMHDR*/, LRESULT* pRes) 
  899. {
  900. *pRes = 0;
  901. }
  902. void CMainFrame::ShowCustomizeDialog(int nSelectedPage)
  903. {
  904. CXTPCustomizeSheet cs(GetCommandBars());
  905. CXTPRibbonCustomizeQuickAccessPage pageQuickAccess(&cs);
  906. cs.AddPage(&pageQuickAccess);
  907. pageQuickAccess.AddCategories(IDR_MAINFRAME);
  908. CXTPCustomizeKeyboardPage pageKeyboard(&cs);
  909. cs.AddPage(&pageKeyboard);
  910. pageKeyboard.AddCategories(IDR_MAINFRAME);
  911. CXTPCustomizeMenusPage pageMenus(&cs);
  912. cs.AddPage(&pageMenus);
  913. CXTPCustomizeOptionsPage pageOptions(&cs);
  914. cs.AddPage(&pageOptions);
  915. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  916. pCommands->AddCategories(IDR_MAINFRAME);
  917. cs.SetActivePage(nSelectedPage);
  918. cs.DoModal();
  919. }
  920. void CMainFrame::OnCustomize()
  921. {
  922. ShowCustomizeDialog(0);
  923. }
  924. void CMainFrame::OnCustomizeQuickAccess()
  925. {
  926. ShowCustomizeDialog(2);
  927. }
  928. void CMainFrame::OnClose() 
  929. {
  930. #ifndef _SAVE_TO_XML
  931. SaveCommandBars(_T("CommandBars2"));
  932. #else
  933. CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
  934. if (px.OnBeforeExchange()) 
  935. {
  936. CXTPPropExchangeSection pxCommandBars(px.GetSection(_T("CommandBars")));
  937. XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; 
  938. param.bSerializeControls = TRUE; 
  939. param.bSaveOriginalControls = FALSE;
  940. param.bSerializeOptions = TRUE;
  941. GetCommandBars()->DoPropExchange(&pxCommandBars, &param);
  942. px.SaveToFile(m_strIniFileName);
  943. }
  944. #endif
  945. CXTPFrameWnd::OnClose();
  946. }
  947. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  948. {
  949. if (lpCreateControl->nID == ID_GALLERY_STYLESET)
  950. {
  951. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  952. pControlGallery->SetControlSize(CSize(200, 22 * 7 + 2));
  953. pControlGallery->SetResizable();
  954. pControlGallery->ShowLabels(TRUE);
  955. pControlGallery->SetItems(m_pItemsStyleSet);
  956. lpCreateControl->pControl = pControlGallery;
  957. return TRUE;
  958. }
  959. if (lpCreateControl->nID == ID_GALLERY_COLORS)
  960. {
  961. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  962. pControlGallery->SetControlSize(CSize(200, 20 * 9 + 2));
  963. pControlGallery->ShowLabels(TRUE);
  964. pControlGallery->SetItems(m_pItemsThemeColors);
  965. lpCreateControl->pControl = pControlGallery;
  966. return TRUE;
  967. }
  968. if (lpCreateControl->nID == ID_GALLERY_FONTBACKCOLOR)
  969. {
  970. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  971. pControlGallery->SetControlSize(CSize(30 * 5, 30 * 3 + 2));
  972. pControlGallery->ShowScrollBar(FALSE);
  973. pControlGallery->SetItems(m_pItemsFontBackColor);
  974. lpCreateControl->pControl = pControlGallery;
  975. return TRUE;
  976. }
  977. if (lpCreateControl->nID == ID_GALLERY_FONTS)
  978. {
  979. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  980. pControlGallery->SetControlSize(CSize(250, 60 * 5 + 2 + 20));
  981. pControlGallery->ShowLabels(TRUE);
  982. pControlGallery->SetItems(m_pItemsThemeFonts);
  983. lpCreateControl->pCommandBar->EnableAnimation();
  984. lpCreateControl->pControl = pControlGallery;
  985. return TRUE;
  986. }
  987. if (lpCreateControl->nID == ID_GALLERY_STYLES)
  988. {
  989. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  990. pControlGallery->SetControlSize(CSize(235 + 72, 56 * 3 + 2));
  991. pControlGallery->SetResizable();
  992. pControlGallery->SetItems(m_pItemsStyles);
  993. lpCreateControl->pControl = pControlGallery;
  994. return TRUE;
  995. }
  996. if (lpCreateControl->nID == ID_GALLERY_SHAPES)
  997. {
  998. CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  999. pControlGallery->SetControlSize(CSize(200, 200));
  1000. pControlGallery->SetResizable();
  1001. pControlGallery->ShowLabels(TRUE);
  1002. pControlGallery->SetItems(m_pItemsShapes);
  1003. lpCreateControl->pControl = pControlGallery;
  1004. return TRUE;
  1005. }
  1006. if (lpCreateControl->nID == ID_CONTENTS_TABLE)
  1007. {
  1008. lpCreateControl->controlType = xtpControlButtonPopup;
  1009. return TRUE;
  1010. }
  1011. if (lpCreateControl->nID >= ID_OPTIONS_STYLEBLUE && lpCreateControl->nID <= ID_OPTIONS_STYLEAQUA)
  1012. {
  1013. lpCreateControl->controlType = xtpControlRadioButton;
  1014. return TRUE;
  1015. }
  1016. if (lpCreateControl->nID >= ID_OPTIONS_FONT_SYSTEM && lpCreateControl->nID <= ID_OPTIONS_FONT_EXTRALARGE)
  1017. {
  1018. lpCreateControl->controlType = xtpControlRadioButton;
  1019. return TRUE;
  1020. }
  1021. if (lpCreateControl->nID == ID_FOOTNOTES_NEXT)
  1022. {
  1023. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  1024. return TRUE;
  1025. }
  1026. if (lpCreateControl->nID == ID_FILE_RECENTDOCUMENTS)
  1027. {
  1028. lpCreateControl->pControl = new CXTPRibbonControlSystemRecentFileList();
  1029. return TRUE;
  1030. }
  1031. if (lpCreateControl->nID == ID_APP_EXIT || lpCreateControl->nID == ID_APP_OPTIONS)
  1032. {
  1033. lpCreateControl->pControl = new CXTPRibbonControlSystemPopupBarButton();
  1034. return TRUE;
  1035. }
  1036. if (lpCreateControl->nID == ID_FILE_PRINT && lpCreateControl->nIndex == 5)
  1037. {
  1038. CXTPControlPopup* pControl = CXTPControlPopup::CreateControlPopup(xtpControlSplitButtonPopup);
  1039. CMenu menu;
  1040. menu.LoadMenu(IDR_MENU_PRINT);
  1041. CXTPRibbonSystemPopupBarPage* pPopupBar = new CXTPRibbonSystemPopupBarPage();
  1042. pPopupBar->SetCommandBars(GetCommandBars());
  1043. pPopupBar->LoadMenu(menu.GetSubMenu(0));
  1044. CXTPControl* pControlLabel = pPopupBar->GetControls()->Add(xtpControlLabel, ID_FILE_PRINT_LABEL, NULL, 0);
  1045. pControlLabel->SetWidth(296);
  1046. pControlLabel->SetItemDefault(TRUE);
  1047. pControlLabel->SetStyle(xtpButtonCaption);
  1048. pPopupBar->SetShowGripper(FALSE);
  1049. pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription);
  1050. pPopupBar->SetIconSize(CSize(32, 32));
  1051. pControl->SetCommandBar(pPopupBar);
  1052. pPopupBar->InternalRelease();
  1053. lpCreateControl->pControl = pControl;
  1054. return TRUE;
  1055. }
  1056. if (lpCreateControl->nID == ID_FILE_SEND)
  1057. {
  1058. CXTPControlPopup* pControl = CXTPControlPopup::CreateControlPopup(xtpControlButtonPopup);
  1059. CMenu menu;
  1060. menu.LoadMenu(IDR_MENU_SEND);
  1061. CXTPRibbonSystemPopupBarPage* pPopupBar = new CXTPRibbonSystemPopupBarPage();
  1062. pPopupBar->SetCommandBars(GetCommandBars());
  1063. pPopupBar->LoadMenu(menu.GetSubMenu(0));
  1064. CXTPControl* pControlLabel = pPopupBar->GetControls()->Add(xtpControlLabel, ID_FILE_SEND_LABEL, NULL, 0);
  1065. pControlLabel->SetWidth(296);
  1066. pControlLabel->SetItemDefault(TRUE);
  1067. pControlLabel->SetStyle(xtpButtonCaption);
  1068. pPopupBar->SetShowGripper(FALSE);
  1069. pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription);
  1070. pPopupBar->SetIconSize(CSize(32, 32));
  1071. pControl->SetCommandBar(pPopupBar);
  1072. pPopupBar->InternalRelease();
  1073. pControl->SetFlags(xtpFlagManualUpdate);
  1074. lpCreateControl->pControl = pControl;
  1075. return TRUE;
  1076. }
  1077. return FALSE;
  1078. }
  1079. void CMainFrame::OnGalleryShapes(NMHDR* pNMHDR, LRESULT* pResult)
  1080. {
  1081. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1082. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1083. if (pGallery)
  1084. {
  1085. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1086. if (pItem)
  1087. {
  1088. m_nShape = pItem->GetID();
  1089. }
  1090. *pResult = TRUE; // Handled
  1091. }
  1092. }
  1093. void CMainFrame::OnUpdateGalleryShapes(CCmdUI* pCmdUI)
  1094. {
  1095. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1096. if (pGallery)
  1097. {
  1098. pGallery->SetCheckedItem(m_nShape);
  1099. }
  1100. pCmdUI->Enable(TRUE);
  1101. }
  1102. void CMainFrame::OnGalleryStyles(NMHDR* pNMHDR, LRESULT* pResult)
  1103. {
  1104. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1105. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1106. if (pGallery)
  1107. {
  1108. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1109. if (pItem)
  1110. {
  1111. m_nStyle = pItem->GetID();
  1112. }
  1113. *pResult = TRUE; // Handled
  1114. }
  1115. }
  1116. void CMainFrame::OnUpdateGalleryStyles(CCmdUI* pCmdUI)
  1117. {
  1118. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1119. if (pGallery)
  1120. {
  1121. if (pGallery->GetCheckedItem() != m_nStyle)
  1122. {
  1123. pGallery->SetCheckedItem(m_nStyle);
  1124. pGallery->EnsureVisible(m_nStyle);
  1125. }
  1126. }
  1127. pCmdUI->Enable(TRUE);
  1128. }
  1129. void CMainFrame::OnGalleryColumns(NMHDR* pNMHDR, LRESULT* pResult)
  1130. {
  1131. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1132. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1133. if (pGallery)
  1134. {
  1135. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1136. if (pItem)
  1137. {
  1138. m_nColumns = pItem->GetID();
  1139. }
  1140. *pResult = TRUE; // Handled
  1141. }
  1142. }
  1143. void CMainFrame::OnUpdateGalleryColumns(CCmdUI* pCmdUI)
  1144. {
  1145. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1146. if (pGallery)
  1147. {
  1148. pGallery->SetCheckedItem(m_nColumns);
  1149. }
  1150. pCmdUI->Enable(TRUE);
  1151. }
  1152. void CMainFrame::OnGalleryStyleSet(NMHDR* pNMHDR, LRESULT* pResult)
  1153. {
  1154. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1155. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1156. if (pGallery)
  1157. {
  1158. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1159. if (pItem)
  1160. {
  1161. m_nStyleSet = pItem->GetID();
  1162. }
  1163. *pResult = TRUE; // Handled
  1164. }
  1165. }
  1166. void CMainFrame::OnUpdateGalleryStyleSet(CCmdUI* pCmdUI)
  1167. {
  1168. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1169. if (pGallery)
  1170. {
  1171. pGallery->SetCheckedItem(m_nStyleSet);
  1172. }
  1173. pCmdUI->Enable(TRUE);
  1174. }
  1175. void CMainFrame::OnGalleryThemeColors(NMHDR* pNMHDR, LRESULT* pResult)
  1176. {
  1177. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1178. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1179. if (pGallery)
  1180. {
  1181. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1182. if (pItem)
  1183. {
  1184. m_nThemeColors = pItem->GetID();
  1185. m_pItemsFontTextColor->RemoveAll();
  1186. pItem = m_pItemsFontTextColor->AddLabel(0);
  1187. pItem->SetCaption(_T("Theme Colors"));
  1188. CGalleryItemFontColor::AddThemeColors(m_pItemsFontTextColor, m_nThemeColors);
  1189. pItem = m_pItemsFontTextColor->AddLabel(0);
  1190. pItem->SetCaption(_T("Standard Colors"));
  1191. CGalleryItemFontColor::AddStandardColors(m_pItemsFontTextColor);
  1192. }
  1193. *pResult = TRUE; // Handled
  1194. }
  1195. }
  1196. void CMainFrame::OnUpdateGalleryThemeColors(CCmdUI* pCmdUI)
  1197. {
  1198. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1199. if (pGallery)
  1200. {
  1201. pGallery->SetCheckedItem(m_nThemeColors);
  1202. }
  1203. pCmdUI->Enable(TRUE);
  1204. }
  1205. void CMainFrame::OnGalleryThemeFonts(NMHDR* pNMHDR, LRESULT* pResult)
  1206. {
  1207. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  1208. CXTPControlGallery* pGallery = DYNAMIC_DOWNCAST(CXTPControlGallery, tagNMCONTROL->pControl);
  1209. if (pGallery)
  1210. {
  1211. CXTPControlGalleryItem* pItem = pGallery->GetItem(pGallery->GetSelectedItem());
  1212. if (pItem)
  1213. {
  1214. m_nThemeFonts = pItem->GetID();
  1215. }
  1216. *pResult = TRUE; // Handled
  1217. }
  1218. }
  1219. void CMainFrame::OnUpdateGalleryThemeFonts(CCmdUI* pCmdUI)
  1220. {
  1221. CXTPControlGallery* pGallery =  DYNAMIC_DOWNCAST(CXTPControlGallery, CXTPControl::FromUI(pCmdUI));
  1222. if (pGallery)
  1223. {
  1224. pGallery->SetCheckedItem(m_nThemeFonts);
  1225. }
  1226. pCmdUI->Enable(TRUE);
  1227. }
  1228. void CMainFrame::OnOptionsAnimation() 
  1229. {
  1230. m_bAnimation ^= 1;
  1231. GetCommandBars()->GetMenuBar()->EnableAnimation(m_bAnimation);
  1232. }
  1233. void CMainFrame::OnUpdateOptionsAnimation(CCmdUI* pCmdUI) 
  1234. {
  1235. pCmdUI->SetCheck(m_bAnimation);
  1236. }
  1237. void CMainFrame::OnOptionsRighttoleft() 
  1238. {
  1239. if (GetExStyle() & WS_EX_LAYOUTRTL)
  1240. {
  1241. GetCommandBars()->SetLayoutRTL(FALSE);
  1242. ModifyStyleEx(WS_EX_LAYOUTRTL, 0);
  1243. ((CWorkspaceView*)GetDlgItem(AFX_IDW_PANE_FIRST))->SetLayoutRTL(FALSE);
  1244. }
  1245. else
  1246. {
  1247. GetCommandBars()->SetLayoutRTL(TRUE);
  1248. ModifyStyleEx(0, WS_EX_LAYOUTRTL);
  1249. ((CWorkspaceView*)GetDlgItem(AFX_IDW_PANE_FIRST))->SetLayoutRTL(TRUE);
  1250. }
  1251. m_wndMessageBar.ModifyStyleEx(WS_EX_LAYOUTRTL, GetExStyle() & WS_EX_LAYOUTRTL);
  1252. }
  1253. void CMainFrame::OnUpdateOptionsRighttoleft(CCmdUI* pCmdUI) 
  1254. {
  1255. if (XTPSystemVersion()->IsLayoutRTLSupported())
  1256. {
  1257. pCmdUI->SetCheck(GetExStyle() & WS_EX_LAYOUTRTL ? TRUE : FALSE);
  1258. }
  1259. else
  1260. {
  1261. pCmdUI->Enable(FALSE);
  1262. }
  1263. }
  1264. void CMainFrame::OnUpdateOptionsStyle(CCmdUI* pCmdUI)
  1265. {
  1266. pCmdUI->SetCheck(pCmdUI->m_nID == m_nRibbonStyle ? 1 : 0);
  1267. }
  1268. void CMainFrame::OnOptionsStyle(UINT nStyle)
  1269. {
  1270. HMODULE hModule = AfxGetInstanceHandle();
  1271. LPCTSTR lpszIniFile = 0;
  1272. switch (nStyle)
  1273. {
  1274. case ID_OPTIONS_STYLEBLUE: 
  1275. lpszIniFile = _T("OFFICE2007BLUE.INI"); break;
  1276. case ID_OPTIONS_STYLEBLACK: 
  1277. lpszIniFile = _T("OFFICE2007BLACK.INI"); break;
  1278. case ID_OPTIONS_STYLEAQUA: 
  1279. lpszIniFile = _T("OFFICE2007AQUA.INI"); break;
  1280. case ID_OPTIONS_STYLESILVER: 
  1281. lpszIniFile = _T("OFFICE2007SILVER.INI"); break;
  1282. }
  1283. ((CXTPOffice2007Theme*)GetCommandBars()->GetPaintManager())->SetImageHandle(hModule, lpszIniFile);
  1284. m_paneManager.GetPaintManager()->RefreshMetrics();
  1285. m_paneStyles.RefreshMetrics();
  1286. m_paneManager.RedrawPanes();
  1287. m_paneStyles.Invalidate();
  1288. GetCommandBars()->GetImageManager()->RefreshAll();
  1289. GetCommandBars()->RedrawCommandBars();
  1290. SendMessage(WM_NCPAINT);
  1291. RedrawWindow(0, 0, RDW_ALLCHILDREN|RDW_INVALIDATE);
  1292. m_nRibbonStyle = nStyle;
  1293. }
  1294. void CMainFrame::OnToggleGroups() 
  1295. {
  1296. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)GetCommandBars()->GetAt(0);
  1297. pRibbonBar->SetRibbonMinimized(!pRibbonBar->IsRibbonMinimized());
  1298. }
  1299. void CMainFrame::OnAutoResizeIcons()
  1300. {
  1301. GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons ^= 1;
  1302. GetCommandBars()->RedrawCommandBars();
  1303. }
  1304. void CMainFrame::OnUpdateAutoResizeIcons(CCmdUI* pCmdUI)
  1305. {
  1306. pCmdUI->SetCheck(GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons);
  1307. }
  1308. int nFonts[] = {0, 11, 13, 16};
  1309. void CMainFrame::OnOptionsFont(UINT nID)
  1310. {
  1311. int nFontHeight = nFonts[nID - ID_OPTIONS_FONT_SYSTEM];
  1312. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)GetCommandBars()->GetAt(0);
  1313. pRibbonBar->SetFontHeight(nFontHeight);
  1314. }
  1315. void CMainFrame::OnUpdateOptionsFont(CCmdUI* pCmdUI)
  1316. {
  1317. int nFontHeight = nFonts[pCmdUI->m_nID - ID_OPTIONS_FONT_SYSTEM];
  1318. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)GetCommandBars()->GetAt(0);
  1319. pCmdUI->SetCheck(pRibbonBar->GetFontHeight() == nFontHeight ? TRUE : FALSE);
  1320. }
  1321. void CMainFrame::OnFrameTheme()
  1322. {
  1323. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)GetCommandBars()->GetAt(0);
  1324. CXTPWindowRect rc(this);
  1325. rc.top += (pRibbonBar->IsFrameThemeEnabled() ? -1 : +1) * GetSystemMetrics(SM_CYCAPTION);
  1326. MoveWindow(rc);
  1327. pRibbonBar->EnableFrameTheme(!pRibbonBar->IsFrameThemeEnabled());
  1328. }
  1329. void CMainFrame::OnUpdateFrameTheme(CCmdUI* pCmdUI)
  1330. {
  1331. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)GetCommandBars()->GetAt(0);
  1332. pCmdUI->SetCheck(pRibbonBar->IsFrameThemeEnabled() ? TRUE : FALSE);
  1333. }
  1334. void CMainFrame::OnStatusBarSwitchView(UINT nID)
  1335. {
  1336. CXTPStatusBarSwitchPane* pPane = (CXTPStatusBarSwitchPane*)m_wndStatusBar.FindPane(ID_INDICATOR_VIEWSHORTCUTS);
  1337. pPane->SetChecked(nID);
  1338. }
  1339. void CMainFrame::OnUpdateKeyIndicator(CCmdUI* pCmdUI)
  1340. {
  1341. CXTPStatusBar* pStatusBar = DYNAMIC_DOWNCAST(CXTPStatusBar, pCmdUI->m_pOther);
  1342. if (!pStatusBar)
  1343. return;
  1344. CXTPStatusBarPane* pPane = pStatusBar->GetPane(pCmdUI->m_nIndex);
  1345. BOOL bVisible = ::GetKeyState(VK_CAPITAL) & 0x0001;
  1346. pPane->SetVisible(bVisible);
  1347. pPane->SetValue(bVisible ? _T("On") : _T("Off"));
  1348. }
  1349. void CMainFrame::OnMacroClick()
  1350. {
  1351. CXTPStatusBarProgressPane* pPane = DYNAMIC_DOWNCAST(CXTPStatusBarProgressPane, m_wndStatusBar.FindPane(ID_INDICATOR_PROGRESS));
  1352. if (!pPane)
  1353. return;
  1354. pPane->SetVisible(TRUE);
  1355. pPane->SetPos(0);
  1356. for (int i = 0; i <= 100; i += 5)
  1357. {
  1358. m_wndStatusBar.UpdateWindow();
  1359. Sleep(1);
  1360. pPane->SetPos(i);
  1361. }
  1362. pPane->SetVisible(FALSE);
  1363. }