// MainFrm.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "RibbonMDISample.h" #include "MainFrm.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CXTPMDIFrameWndEx) BEGIN_MESSAGE_MAP(CMainFrame, CXTPMDIFrameWndEx) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_WM_GETMINMAXINFO() ON_WM_SETTINGCHANGE() ON_COMMAND(ID_WINDOW_ARRANGE, OnWindowArrange) ON_COMMAND(ID_WINDOW_CASCADE, OnWindowCascade) ON_COMMAND(ID_WINDOW_TILE_HORZ, OnWindowTileHorz) ON_COMMAND(ID_WINDOW_TILE_VERT, OnWindowTileVert) ON_COMMAND(ID_VIEW_NORMAL, OnEmptyCommand) ON_UPDATE_COMMAND_UI(ID_VIEW_NORMAL, OnUpdateEmptyCommand) ON_COMMAND(ID_VIEW_FULLSCREEN, OnEmptyCommand) ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateEmptyCommand) ON_UPDATE_COMMAND_UI(ID_WINDOW_SWITCH, OnUpdateWindowSwitch) ON_COMMAND(ID_VIEW_WORKSPACE, OnViewWorkspace) ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateViewWorkspace) // ON_UPDATE_COMMAND_UI(ID_WINDOW_MANAGER, &CMainFrame::OnUpdateEnableMDIWindows) !! // ON_COMMAND(XTP_ID_CUSTOMIZE, &CMainFrame::OnCustomize) // ON_COMMAND(XTP_ID_RIBBONCUSTOMIZE, &CMainFrame::OnCustomizeQuickAccess) // ON_COMMAND(ID_BACKSTAGE_OPTIONS, &CMainFrame::OnCustomize) // ON_COMMAND_RANGE(ID_OPTIONS_STYLE_FIRST, ID_OPTIONS_STYLE_LAST, &CMainFrame::OnOptionsStyle) // ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_STYLE_FIRST, ID_OPTIONS_STYLE_LAST, // &CMainFrame::OnUpdateOptionsStyle) ON_WM_XTP_THEMECHANGED() ON_COMMAND(ID_OPTIONS_STYLE_THEMEDIALOG, OnThemeDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() : m_bThemeApplied(FALSE) , m_nAppliedTheme(xtpThemeNone) , m_pRibbonBar(NULL) , m_pBackstageView(NULL) , m_bShowWorkspace(TRUE) { } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) { TRACE(_T("ERROR: Failed to create main frame.\n")); return -1; } // Default menu has to be disabled so that it does not overlap CommandBars SetMenu(NULL); if (!CreateStatusBar()) { TRACE(_T("ERROR: Failed to create the status bar.\n")); return -1; } if (!InitCommandBars()) { TRACE(_T("ERROR: Failed to initialize command bars.\n")); return -1; } if (!CreateRibbonBar()) { TRACE(_T("ERROR: Failed to initialize the ribbon bar.\n")); return -1; } ModifyStyle(0, FWS_PREFIXTITLE); if (!CreateTabClient()) { TRACE(_T("ERROR: Failed to create tab client.\n")); return -1; } LoadXAMLIcons(); InitTooltips(); InitThemeDlg(); CenterWindow(); return 0; } void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { lpMMI->ptMinTrackSize.x = XTP_DPI_X(300); lpMMI->ptMinTrackSize.y = XTP_DPI_Y(300); CXTPMDIFrameWndEx::OnGetMinMaxInfo(lpMMI); } void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { CXTPMDIFrameWndEx::OnSettingChange(uFlags, lpszSection); } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if (!CXTPMDIFrameWndEx::PreCreateWindow(cs)) return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | FWS_ADDTOTITLE; cs.lpszClass = _T("RibbonMDISample"); CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } CXTPDockingPaneManager* CMainFrame::GetDockingPaneManager() { return NULL; } CXTPTabClientWnd* CMainFrame::GetTabClientWnd() { return &m_wndTabClient; } void CMainFrame::InitThemeDlg() { // exclude unused themes. m_dlgTheme.ExcludeTheme( XTP_EXCLUDE_THEME_VISUALSTUDIO6 | XTP_EXCLUDE_THEME_VISUALSTUDIO2005 | XTP_EXCLUDE_THEME_VISUALSTUDIO2008 | XTP_EXCLUDE_THEME_VISUALSTUDIO2010 | XTP_EXCLUDE_THEME_VISUALSTUDIO2012 | XTP_EXCLUDE_THEME_OFFICE2000 | XTP_EXCLUDE_THEME_OFFICEXP | XTP_EXCLUDE_THEME_OFFICE2003 | XTP_EXCLUDE_THEME_CUSTOM); // create theme dialog. VERIFY(m_dlgTheme.Create(IDD_THEME_DIALOG, this)); // set startup theme m_dlgTheme.SetTheme(xtpThemeDlgOffice2016, xtpThemeColor2016Colorful, xtpThemeAccentWord, xtpThemeRibbonBackUndef, TRUE); // enable auto preview. m_dlgTheme.EnableAutoPreview(TRUE); } void CMainFrame::OnThemeDlg() { m_dlgTheme.ShowWindow(SW_SHOW); } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CMDIFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CMDIFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers LRESULT CMainFrame::OnThemeChanged(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(wParam); CWaitCursor wait; // Disable previous theme. EnableTheme(m_nAppliedTheme, m_strAppliedThemeSettings, FALSE); THEME_COLOR* pThemeColor = reinterpret_cast(lParam); int nTheme = pThemeColor->nTheme; int nColor = pThemeColor->nColor; int nAccent = pThemeColor->nAccent; XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast(pThemeColor->nAccent)); XTPGetApplication()->SetAmbientProperty(xtpApplicationUseSystemAccentColor, static_cast(pThemeColor->bUseSystemAccent)); switch (nTheme) { case xtpThemeDlgOffice2007: { switch (nColor) { case xtpThemeColor2007Blue: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Blue); break; case xtpThemeColor2007Silver: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Silver); break; case xtpThemeColor2007Black: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Black); break; case xtpThemeColor2007Aqua: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Aqua); break; case xtpThemeColor2007System: theApp.SetAppTheme(xtpThemeOffice2007System); break; } } break; case xtpThemeDlgOffice2010: { switch (nColor) { case xtpThemeColor2010Blue: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Blue); break; case xtpThemeColor2010Silver: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Silver); break; case xtpThemeColor2010Black: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Black); break; } } break; case xtpThemeDlgOffice2013: { switch (nColor) { case xtpThemeColor2013White: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Access); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Excel); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNote); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Outlook); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPoint); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Publisher); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Word); break; } } break; case xtpThemeColor2013GrayLight: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013AccessGrayLight); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013ExcelGrayLight); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNoteGrayLight); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OutlookGrayLight); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPointGrayLight); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PublisherGrayLight); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013WordGrayLight); break; } } break; case xtpThemeColor2013GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013AccessGrayDark); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013ExcelGrayDark); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNoteGrayDark); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OutlookGrayDark); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPointGrayDark); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PublisherGrayDark); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013WordGrayDark); break; } } break; } } break; case xtpThemeDlgOffice2016: { switch (nColor) { case xtpThemeColor2016Black: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessBlack); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelBlack); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteBlack); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookBlack); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointBlack); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherBlack); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordBlack); break; } } break; case xtpThemeColor2016White: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessWhite); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelWhite); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteWhite); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookWhite); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointWhite); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherWhite); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordWhite); break; } } break; case xtpThemeColor2016Colorful: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessColorful); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelColorful); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteColorful); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookColorful); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointColorful); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherColorful); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordColorful); break; } } break; case xtpThemeColor2016GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessDarkGray); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelDarkGray); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteDarkGray); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookDarkGray); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointDarkGray); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherDarkGray); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordDarkGray); break; } } break; } } break; case xtpThemeDlgVisualStudio2015: { switch (nColor) { case xtpThemeColor2015Blue: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Blue); break; case xtpThemeColor2015Dark: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Dark); break; case xtpThemeColor2015Light: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Light); break; } } break; case xtpThemeDlgVisualStudio2017: { switch (nColor) { case xtpThemeColor2017Blue: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Blue); break; case xtpThemeColor2017BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017BlueExtra); break; case xtpThemeColor2017Dark: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Dark); break; case xtpThemeColor2017Light: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Light); break; } } break; case xtpThemeDlgVisualStudio2019: { switch (nColor) { case xtpThemeColor2019Blue: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Blue); break; case xtpThemeColor2019BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019BlueExtra); break; case xtpThemeColor2019Dark: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Dark); break; case xtpThemeColor2019Light: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Light); break; } } break; case xtpThemeDlgVisualStudio2022: { switch (nColor) { case xtpThemeColor2022Blue: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Blue); break; case xtpThemeColor2022BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022BlueExtra); break; case xtpThemeColor2022Dark: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Dark); break; case xtpThemeColor2022Light: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Light); break; } } break; case xtpThemeDlgNativeWindows: theApp.SetAppTheme(xtpThemeResource, xtpIniWindows7Blue); break; case xtpThemeDlgNativeWindows10: { switch (nColor) { case xtpThemeColorWindows10Light: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); theApp.SetAppTheme(xtpThemeNativeWindows10, xtpIniWindows10Light); break; case xtpThemeColorWindows10Dark: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); theApp.SetAppTheme(xtpThemeNativeWindows10, xtpIniWindows10Dark); break; } } break; case xtpThemeDlgNativeWindows11: { switch (nColor) { case xtpThemeColorWindows11Light: theApp.SetAppTheme(xtpThemeNativeWindows11, xtpIniWindows11Light); break; case xtpThemeColorWindows11Dark: theApp.SetAppTheme(xtpThemeNativeWindows11, xtpIniWindows11Dark); break; } } break; } UpdateTheme(); return 0; } void CMainFrame::EnableTheme(XTPPaintTheme nTheme, LPCTSTR lpzThemeSettings, BOOL bEnable /*= TRUE*/) { _ASSERTE(NULL != lpzThemeSettings); switch (nTheme) { case xtpThemeNone: EnableNoStyle(bEnable); break; case xtpThemeOffice2013: if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2013"))) { EnableStyleOffice2013(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2016"))) { EnableStyleOffice2016(bEnable); } else { _ASSERTE(!"Unexpected theme settings"); } break; case xtpThemeVisualStudio2015: EnableStyleVisualStudio2015(bEnable); break; case xtpThemeVisualStudio2017: EnableStyleVisualStudio2017(bEnable); break; case xtpThemeVisualStudio2019: EnableStyleVisualStudio2019(bEnable); break; case xtpThemeVisualStudio2022: EnableStyleVisualStudio2022(bEnable); break; case xtpThemeNativeWindows10: EnableStyleWindows10(bEnable); break; case xtpThemeNativeWindows11: EnableStyleWindows11(bEnable); break; case xtpThemeResource: if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2007"))) { EnableStyleOffice2007(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2010"))) { EnableStyleOffice2010(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("WINDOWS7"))) { EnableStyleWindows7(bEnable); } else { _ASSERTE(!"Unexpected theme settings"); } break; case xtpThemeOffice2007System: EnableStyleOffice2007(bEnable); break; default: _ASSERTE(!"Unsupported theme"); break; } } void CMainFrame::UpdateTheme() { XTPPaintTheme nNewTheme = theApp.GetAppTheme(); CString strNewThemeSettings = theApp.GetAppThemeSettings(); if (m_bThemeApplied && m_nAppliedTheme == nNewTheme && m_strAppliedThemeSettings == strNewThemeSettings) { // No change required. return; } CWaitCursor wait; // Enable new theme. EnableTheme(nNewTheme, strNewThemeSettings); m_nAppliedTheme = nNewTheme; m_strAppliedThemeSettings = strNewThemeSettings; CXTPCommandBars* pCommandBars = GetCommandBars(); pCommandBars->GetPaintManager()->m_bAutoResizeIcons = TRUE; pCommandBars->GetPaintManager()->RefreshMetrics(); pCommandBars->GetImageManager()->RefreshAll(); pCommandBars->RedrawCommandBars(); m_wndTabClient.GetPaintManager()->RefreshMetrics(); SendMessage(WM_NCPAINT); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE); } BOOL CMainFrame::CreateRibbonBar() { CMenu menu; menu.Attach(::GetMenu(m_hWnd)); SetMenu(NULL); CXTPCommandBars* pCommandBars = GetCommandBars(); if (!pCommandBars) { return FALSE; } pCommandBars->RemoveAll(); m_pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, pCommandBars->Add(_T("The Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar))); if (!m_pRibbonBar) { return FALSE; } CXTPControlPopup* pRibbonButton = DYNAMIC_DOWNCAST(CXTPControlPopup, m_pRibbonBar->AddSystemButton(ID_RIBBON_MENU)); if (pRibbonButton) pRibbonButton->SetIconId(IDB_GEAR); UINT uCommand = { IDB_GEAR }; pCommandBars->GetImageManager()->SetIcons(IDB_GEAR, &uCommand, 1, CSize(0, 0), xtpImageNormal); CreateRibbonTab_Home(); CreateRibbonTab_Edit(); CreateRibbonTab_View(); CXTPControlPopup* pControlOptions = DYNAMIC_DOWNCAST(CXTPControlPopup, m_pRibbonBar->GetControls()->Add(xtpControlPopup, -1)); if (pControlOptions) { pControlOptions->SetFlags(xtpFlagRightAlign); CMenu mnuOptions; mnuOptions.LoadMenu(IDR_MENU_OPTIONS); pControlOptions->SetCommandBar(mnuOptions.GetSubMenu(0)); pControlOptions->SetCaption(_T("Options")); } CXTPControl* pControlAbout = m_pRibbonBar->GetControls()->Add(xtpControlButton, ID_APP_ABOUT); if (pControlAbout) pControlAbout->SetFlags(xtpFlagRightAlign); m_pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_SAVE); m_pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_EDIT_UNDO); m_pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_EDIT_REDO); m_pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_PRINT); m_pRibbonBar->GetQuickAccessControls()->CreateOriginalControls(); GetCommandBars()->GetPaintManager()->RefreshMetrics(); GetCommandBars()->RedrawCommandBars(); return TRUE; } void CMainFrame::CreateRibbonTab_Home() { ASSERT_VALID(m_pRibbonBar); CXTPRibbonTab* pTab = m_pRibbonBar->AddTab(ID_TAB_HOME); if (pTab) { CXTPRibbonGroup* pGroupFile = pTab->AddGroup(ID_GROUP_FILE); if (pGroupFile) { pGroupFile->Add(xtpControlButton, ID_FILE_NEW); pGroupFile->Add(xtpControlButton, ID_FILE_OPEN); CXTPControlPopup* pControlSave = (CXTPControlPopup*)pGroupFile->Add(xtpControlSplitButtonPopup, ID_FILE_SAVE); if (pControlSave) { pControlSave->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_FILE_SAVE); pControlSave->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_FILE_SAVE_AS); } pGroupFile->Add(xtpControlButton, ID_FILE_CLOSE); } CXTPControlPopup* pControlPrint = (CXTPControlPopup*)pGroupFile->Add(xtpControlSplitButtonPopup, ID_FILE_PRINT); if (pControlPrint) { pControlPrint->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_FILE_PRINT); pControlPrint->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_FILE_PRINT_SETUP); pControlPrint->SetBeginGroup(TRUE); } } } void CMainFrame::CreateRibbonTab_Edit() { ASSERT_VALID(m_pRibbonBar); CXTPRibbonTab* pTab = m_pRibbonBar->AddTab(ID_TAB_EDIT); if (pTab) { CXTPRibbonGroup* pGroupClipboard = pTab->AddGroup(ID_GROUP_CLIPBOARD); if (pGroupClipboard) { pGroupClipboard->ShowOptionButton(); CXTPControlPopup* pControlPaste = (CXTPControlPopup*)pGroupClipboard->Add(xtpControlSplitButtonPopup, ID_EDIT_PASTE); if (pControlPaste) { pControlPaste->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_PASTE); pControlPaste->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_PASTE_SPECIAL); } pGroupClipboard->Add(xtpControlButton, ID_EDIT_CUT); pGroupClipboard->Add(xtpControlButton, ID_EDIT_COPY); pGroupClipboard->Add(xtpControlButton, ID_CLIPBOARD_FORMAT_PAINTER); } CXTPRibbonGroup* pGroupEditing = pTab->AddGroup(ID_GROUP_EDITING); if (pGroupEditing) { pGroupEditing->Add(xtpControlButton, ID_EDIT_FIND); pGroupEditing->Add(xtpControlButton, ID_EDIT_REPLACE); pGroupEditing->Add(xtpControlButton, ID_EDIT_GOTO); CXTPControlPopup* pControlSelect = (CXTPControlPopup*)pGroupEditing->Add(xtpControlPopup, ID_EDIT_SELECT); if (pControlSelect) { pControlSelect->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_EDIT_SELECT_ALL); pControlSelect->SetFlags(xtpFlagManualUpdate); } } } } void CMainFrame::CreateRibbonTab_View() { ASSERT_VALID(m_pRibbonBar); CXTPRibbonTab* pTab = m_pRibbonBar->AddTab(ID_TAB_VIEW); if (pTab) { CXTPRibbonGroup* pGroupDocumentViews = pTab->AddGroup(ID_GROUP_DOCUMENTVIEWS); if (pGroupDocumentViews) { pGroupDocumentViews->Add(xtpControlButton, ID_VIEW_NORMAL); pGroupDocumentViews->Add(xtpControlButton, ID_FILE_PRINT_PREVIEW); pGroupDocumentViews->Add(xtpControlButton, ID_VIEW_FULLSCREEN); } CXTPRibbonGroup* pGroupShowHide = pTab->AddGroup(ID_GROUP_SHOWHIDE); if (pGroupShowHide) { pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_STATUS_BAR); pGroupShowHide->Add(xtpControlCheckBox, ID_VIEW_WORKSPACE); } CXTPRibbonGroup* pGroupWindow = pTab->AddGroup(ID_GROUP_WINDOW); if (pGroupWindow) { pGroupWindow->Add(xtpControlButton, ID_WINDOW_NEW); pGroupWindow->Add(xtpControlButton, ID_WINDOW_TILE_VERT); pGroupWindow->Add(xtpControlButton, ID_WINDOW_CASCADE); pGroupWindow->Add(xtpControlButton, ID_WINDOW_TILE_HORZ); CXTPControlPopup* pControlSwitchWindows = (CXTPControlPopup*)pGroupWindow->Add(xtpControlPopup, ID_WINDOW_SWITCH); pControlSwitchWindows->GetCommandBar()->GetControls()->Add(xtpControlButton, XTP_ID_WINDOWLIST); } } } void CMainFrame::CreateSystemMenuPopup() { CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetMenuBar()); if (pRibbonBar) { pRibbonBar->GetSystemButton()->SetStyle(xtpButtonAutomatic); CXTPRibbonControlSystemButton* pRibbonButton = pRibbonBar->GetSystemButton(); if (pRibbonButton) { CMenu menu; menu.LoadMenu(IDR_MAINFRAME); CXTPPopupBar* pCommandBar = new CXTPRibbonSystemPopupBar(); if (pCommandBar) { pCommandBar->SetCommandBars(GetCommandBars()); pRibbonButton->SetCommandBar(pCommandBar); pCommandBar->InternalRelease(); pCommandBar->LoadMenu(menu.GetSubMenu(0)); pCommandBar->SetIconSize(CSize(36, 36)); } } } } void CMainFrame::CreateBackstage() { _ASSERTE(NULL == m_pBackstageView); ASSERT_VALID(m_pRibbonBar); m_pBackstageView = CXTPRibbonBackstageView::CreateBackstageView(GetCommandBars()); ASSERT_VALID(m_pBackstageView); if (m_pBackstageView) { m_pBackstageView->AddCommand(ID_FILE_OPEN); m_pBackstageView->AddCommand(ID_FILE_SAVE); m_pBackstageView->AddCommand(ID_FILE_SAVE_AS); m_pBackstageView->AddCommand(ID_FILE_PRINT); m_pBackstageView->AddCommand(ID_APP_ABOUT); m_pBackstageView->AddMenuSeparator(); m_pBackstageView->AddCommand(ID_APP_EXIT); CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetMenuBar()); if (pRibbonBar) { pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); CXTPRibbonControlSystemButton* pRibbonButton = pRibbonBar->GetSystemButton(); if (pRibbonButton) { pRibbonButton->SetCommandBar(m_pBackstageView); } } m_pBackstageView->InternalRelease(); } } void CMainFrame::DestroyBackstage() { ASSERT_VALID(m_pBackstageView); ASSERT_VALID(m_pRibbonBar); m_pBackstageView = NULL; } BOOL CMainFrame::CreateStatusBar() { _ASSERTE(!::IsWindow(m_wndStatusBar)); static const UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; if (!m_wndStatusBar.Create(this)) { TRACE(_T("ERROR: Unable to create status bar.\n")); return FALSE; } m_wndStatusBar.SetIndicators(indicators, _countof(indicators)); return TRUE; } BOOL CMainFrame::CreateTabClient() { if (!m_wndTabClient.Attach(this, FALSE)) { TRACE(_T("ERROR: Unable to create tab client.\n")); return FALSE; } m_wndTabClient.EnableToolTips(); m_wndTabClient.GetPaintManager()->m_bShowIcons = TRUE; m_wndTabClient.SetFlags(xtpWorkspaceShowCloseTab); return TRUE; } void CMainFrame::InitTooltips() { CXTPToolTipContext* pToolTipContext = GetCommandBars()->GetToolTipContext(); ASSERT_VALID(pToolTipContext); pToolTipContext->ShowTitleAndDescription(); pToolTipContext->ShowImage(TRUE, 0); pToolTipContext->SetMargin(XTP_DPI(CRect(2, 2, 2, 2))); pToolTipContext->SetMaxTipWidth(XTP_DPI_X(180)); pToolTipContext->SetFont(GetCommandBars()->GetPaintManager()->GetIconFont()); pToolTipContext->SetDelayTime(TTDT_INITIAL, 900); } void CMainFrame::SetTooltipStyle(XTPToolTipStyle nStyle) { CXTPToolTipContext* pToolTipContext = NULL; // Update tooltip styles. pToolTipContext = m_wndStatusBar.GetToolTipContext(); if (NULL != pToolTipContext) { pToolTipContext->SetStyle(nStyle); } pToolTipContext = GetCommandBars()->GetToolTipContext(); if (NULL != pToolTipContext) { pToolTipContext->SetStyle(nStyle); } } void CMainFrame::SetFrameIcon(CSize szIcon) { HICON hIcon = reinterpret_cast(::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, szIcon.cx, szIcon.cy, LR_SHARED)); if (NULL == hIcon) { TRACE(_T("ERROR: Unable to load frame icon.\n")); return; } GetCommandBars()->GetPaintManager()->GetFramePaintManager()->SetIcon(hIcon, szIcon); } void CMainFrame::UpdateChildrenTheme() { UpdateMDIChildrenTheme(); } void CMainFrame::DisableStyle() { SetTooltipStyle(xtpToolTipStandard); DisableFrameTheme(); ASSERT_VALID(m_pRibbonBar); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonAutomatic); UpdateChildrenTheme(); } void CMainFrame::EnableNoStyle(BOOL bEnable /*= TRUE*/) { if (bEnable) { CXTPCommandBarsFrameHook::m_bAllowDwm = FALSE; EnableFrameTheme(GetCommandBars()); } else { DisableFrameTheme(); } UpdateChildrenTheme(); } void CMainFrame::EnableStyleOffice2007(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetTooltipStyle(xtpToolTipOffice2007); EnableFrameTheme(GetCommandBars()); CreateSystemMenuPopup(); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipOffice); EnableFrameTheme(GetCommandBars()); CreateBackstage(); ASSERT_VALID(m_pBackstageView); m_pBackstageView->SetTheme(xtpThemeRibbon); m_pBackstageView->SetBackstageStyle(xtpRibbonBackstageOffice2010Style); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { DestroyBackstage(); DisableStyle(); } } void CMainFrame::EnableStyleOffice2013(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); SetTooltipStyle(xtpToolTipOffice2013); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateBackstage(); ASSERT_VALID(m_pBackstageView); m_pBackstageView->SetTheme(xtpThemeOffice2013); m_pBackstageView->SetBackstageStyle(xtpRibbonBackstageOffice2013Style); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { DestroyBackstage(); GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleOffice2016(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipOffice2016); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateBackstage(); ASSERT_VALID(m_pBackstageView); m_pBackstageView->SetTheme(xtpThemeOffice2016); m_pBackstageView->SetBackstageStyle(xtpRibbonBackstageOffice2016Style); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { DestroyBackstage(); SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2015(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2017(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2019(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2022(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleWindows7(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleWindows10(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); // TODO: Leave COLORREF_NULL as an accent color to get system accent color // or specify any custom RGB accent color value. XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, COleVariant(static_cast(COLORREF_NULL), VT_I4)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleWindows11(BOOL bEnable /*= TRUE*/) { if (bEnable) { ASSERT_VALID(m_pRibbonBar); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); // TODO: Leave COLORREF_NULL as an accent color to get system accent color // or specify any custom RGB accent color value. XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, COleVariant(static_cast(COLORREF_NULL), VT_I4)); CreateSystemMenuPopup(); m_pRibbonBar->GetSystemButton()->SetStyle(xtpButtonCaption); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::OnUpdateEnableMDIWindows(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->Enable(MDIGetActive() != NULL); } void CMainFrame::OnWindowArrange() { MDIIconArrange(); } void CMainFrame::OnWindowCascade() { MDICascade(); } void CMainFrame::OnWindowTileHorz() { MDITile(MDITILE_HORIZONTAL); } void CMainFrame::OnWindowTileVert() { MDITile(MDITILE_VERTICAL); } void CMainFrame::LoadXAMLIcons() { CString type(_T("RT_XAML")); // resource type UINT nWidth = 0; // COMMON // Normal icons nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_DOCUMENT, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_OPEN_FILLED, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE_FILLED, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE_AS_FILLED, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_UNDO_2, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_REDO_2, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_DOCUMENT, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_OPEN_FILLED, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE_FILLED, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE_AS_FILLED, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_UNDO_2, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_REDO_2, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth); // Disabled icons nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_DOCUMENT, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_OPEN_FILLED, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE_FILLED, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE_AS_FILLED, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_UNDO_2, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_REDO_2, ID_EDIT_REDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_DOCUMENT, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_OPEN_FILLED, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE_FILLED, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE_AS_FILLED, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_UNDO_2, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_REDO_2, ID_EDIT_REDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth, xtpImageDisabled); // Edit // Normal icons nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_PASTE_BLANK, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FIND, ID_EDIT_FIND, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_POINTER, ID_EDIT_SELECT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SPELL_CHECK, ID_EDIT_GOTO, nWidth); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_PASTE_BLANK, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FIND, ID_EDIT_FIND, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_POINTER, ID_EDIT_SELECT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SPELL_CHECK, ID_EDIT_GOTO, nWidth); // Disabled icons nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_PASTE_BLANK, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FIND, ID_EDIT_FIND, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_POINTER, ID_EDIT_SELECT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SPELL_CHECK, ID_EDIT_GOTO, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_PASTE_BLANK, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLEANUP, ID_CLIPBOARD_FORMAT_PAINTER, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FIND, ID_EDIT_FIND, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_POINTER, ID_EDIT_SELECT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SPELL_CHECK, ID_EDIT_GOTO, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_BOOK_OPEN, ID_VIEW_NORMAL, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FULLSCREEN, ID_VIEW_FULLSCREEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOW_NEW, ID_WINDOW_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOW_ARRANGE_VERTICAL, ID_WINDOW_TILE_VERT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOW_ARRANGE_HORIZONTAL, ID_WINDOW_TILE_HORZ, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOWS, ID_WINDOW_CASCADE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOW, ID_WINDOW_SWITCH, nWidth); // XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_WINDOW, ID_GROUP_WINDOW, // nWidth); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_BOOK_OPEN, ID_VIEW_NORMAL, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FULLSCREEN, ID_VIEW_FULLSCREEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOW_NEW, ID_WINDOW_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOW_ARRANGE_VERTICAL, ID_WINDOW_TILE_VERT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOW_ARRANGE_HORIZONTAL, ID_WINDOW_TILE_HORZ, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOWS, ID_WINDOW_CASCADE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOW, ID_WINDOW_SWITCH, nWidth); // XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_WINDOW, ID_GROUP_WINDOW, // nWidth); // Disabled icons nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_BOOK_OPEN, ID_VIEW_NORMAL, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FULLSCREEN, ID_VIEW_FULLSCREEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOW_NEW, ID_WINDOW_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOW_ARRANGE_VERTICAL, ID_WINDOW_TILE_VERT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOW_ARRANGE_HORIZONTAL, ID_WINDOW_TILE_HORZ, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOWS, ID_WINDOW_CASCADE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOW, ID_WINDOW_SWITCH, nWidth, xtpImageDisabled); // XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_WINDOW, ID_GROUP_WINDOW, // nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_BOOK_OPEN, ID_VIEW_NORMAL, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FULLSCREEN, ID_VIEW_FULLSCREEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOW_NEW, ID_WINDOW_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOW_ARRANGE_VERTICAL, ID_WINDOW_TILE_VERT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOW_ARRANGE_HORIZONTAL, ID_WINDOW_TILE_HORZ, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOWS, ID_WINDOW_CASCADE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOW, ID_WINDOW_SWITCH, nWidth, xtpImageDisabled); // XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_WINDOW, ID_GROUP_WINDOW, // nWidth, xtpImageDisabled); } void CMainFrame::OnEmptyCommand() { AfxMessageBox(_T("TODO: Add your command handler")); } void CMainFrame::OnUpdateEmptyCommand(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->Enable(TRUE); } void CMainFrame::OnViewWorkspace() { m_bShowWorkspace ^= 1; GetTabClientWnd()->ShowWorkspace(m_bShowWorkspace); } void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_bShowWorkspace); } void CMainFrame::OnUpdateWindowSwitch(CCmdUI* pCmdUI) { pCmdUI->Enable(MDIGetActive() != NULL ? TRUE : FALSE); }