// 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 "CommandBarControls.h" #include "CommandBarControlsView.h" #include "MainFrm.h" #ifdef _DEBUG # define new DEBUG_NEW #endif IMPLEMENT_DYNCREATE(CMainFrame, CXTPMDIFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CXTPMDIFrameWnd) ON_WM_CREATE() ON_WM_GETMINMAXINFO() ON_WM_SETTINGCHANGE() ON_WM_XTP_THEMECHANGED() ON_XTP_CREATECONTROL() 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_UPDATE_COMMAND_UI(ID_WINDOW_MANAGER, OnUpdateEnableMDIWindows) ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize) ON_COMMAND(ID_THEME, OnThemeDlg) ON_COMMAND(ID_OPTIONS_RIGHTTOLEFT, OnOptionsRighttoleft) ON_UPDATE_COMMAND_UI(ID_OPTIONS_RIGHTTOLEFT, OnUpdateOptionsRighttoleft) END_MESSAGE_MAP() CMainFrame::CMainFrame() : m_bThemeApplied(FALSE) , m_nAppliedTheme(xtpThemeNone) , m_pMenuTitleBar(NULL) , m_pMenuBar(NULL) , m_pToolBarButtons(NULL) , m_pToolBarPopups(NULL) , m_pToolBarCombo(NULL) , m_pToolBarEdit(NULL) , m_pToolBarRadio(NULL) , m_pToolBarCheckBox(NULL) , m_pToolBarListBox(NULL) , m_pToolBarGallery(NULL) , m_pToolBarColor(NULL) , m_pToolBarSlider(NULL) , m_pToolBarScrollBar(NULL) , m_pToolBarProgress(NULL) , m_pWorkspaceBar(NULL) { } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (BaseFrame::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 (!CreateToolbars()) { TRACE(_T("ERROR: Failed to create toolbars.\n")); return -1; } ModifyStyle(0, FWS_PREFIXTITLE); LoadVectorIcons(); InitTooltips(); InitThemeDlg(); CenterWindow(); return 0; } void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { lpMMI->ptMinTrackSize.x = XTP_DPI_X(1280); lpMMI->ptMinTrackSize.y = XTP_DPI_Y(720); BaseFrame::OnGetMinMaxInfo(lpMMI); } int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl) { _ASSERTE(NULL != lpCreateControl); if (!lpCreateControl->bToolBar) return FALSE; CXTPToolBar* pToolBar = DYNAMIC_DOWNCAST(CXTPToolBar, lpCreateControl->pCommandBar); ASSERT_VALID(pToolBar); switch (pToolBar->GetBarID()) { case IDR_MAINFRAME: switch (lpCreateControl->nID) { case ID_FILE_NEW: // lpCreateControl->controlType = xtpControlSplitButtonPopup; return TRUE; case ID_FILE_OPEN: // lpCreateControl->controlType = xtpControlSplitButtonPopup; return TRUE; } break; } return FALSE; } void CMainFrame::EnableTheme(XTPPaintTheme nTheme, LPCTSTR lpzThemeSettings, BOOL bEnable /*= TRUE*/) { if (m_nAppliedTheme != nTheme) { BOOL bMenuTheme = (m_nAppliedTheme != xtpThemeVisualStudio2019 && m_nAppliedTheme != xtpThemeVisualStudio2022); BOOL bTitleBarTheme = (m_nAppliedTheme == xtpThemeVisualStudio2019 || m_nAppliedTheme == xtpThemeVisualStudio2022); BOOL bNewMenuTheme = (nTheme != xtpThemeVisualStudio2019 && nTheme != xtpThemeVisualStudio2022); BOOL bNewTitleBarTheme = (nTheme == xtpThemeVisualStudio2019 || nTheme == xtpThemeVisualStudio2022); if ((bMenuTheme && bNewTitleBarTheme) || (bTitleBarTheme && bNewMenuTheme)) { ASSERT(UpdateMenuBar(nTheme)); } } _ASSERTE(NULL != lpzThemeSettings); switch (nTheme) { case xtpThemeNone: EnableNoStyle(bEnable); break; case xtpThemeOffice2000: EnableStyleOffice2000(bEnable); break; case xtpThemeOfficeXP: EnableStyleOfficeXP(bEnable); break; case xtpThemeOffice2003: EnableStyleOffice2003(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 xtpThemeVisualStudio6: EnableStyleVisualStudio6(bEnable); break; case xtpThemeVisualStudio2005: EnableStyleVisualStudio2005(bEnable); break; case xtpThemeVisualStudio2008: EnableStyleVisualStudio2008(bEnable); break; case xtpThemeVisualStudio2010: EnableStyleVisualStudio2010(bEnable); break; case xtpThemeVisualStudio2015: EnableStyleVisualStudio2015(bEnable); break; case xtpThemeVisualStudio2017: EnableStyleVisualStudio2017(bEnable); break; case xtpThemeVisualStudio2019: EnableStyleVisualStudio2019(bEnable); break; case xtpThemeVisualStudio2022: EnableStyleVisualStudio2022(bEnable); break; case xtpThemeNativeWinXP: EnableStyleWindowsXP(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: EnableStyleOffice2007System(bEnable); break; case xtpThemeRibbon: EnableStyleRibbon(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(); // if (m_wndTabClient) m_wndTabClient.GetPaintManager()->RefreshMetrics(); SendMessage(WM_NCPAINT); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE); } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if (!BaseFrame::PreCreateWindow(cs)) return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | FWS_ADDTOTITLE; cs.lpszClass = _T("XTPMainFrame"); CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); cs.cx = XTP_DPI_X(1280); cs.cy = XTP_DPI_Y(720); return TRUE; } BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { BOOL bHandled = FALSE; if (XTP_CN_UPDATE_CUSTOMIZE_COMMAND_UI == nCode) { // Manually added toolbar controls have to be made enabled explicitly if necessary. CXTPControl** pControls = reinterpret_cast(pExtra); CXTPControl* pCustomizedMenuControl = pControls[0]; CXTPControl* pControl = pControls[1]; _ASSERTE(nID == (UINT)pControl->GetID()); pCustomizedMenuControl->SetEnabled(TRUE); bHandled = TRUE; } return bHandled ? TRUE : CXTPMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } 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::CreateToolbars() { CXTPCommandBars* pCommandBars = GetCommandBars(); if (NULL == pCommandBars) { TRACE0("Failed to create command bars object.\n"); return FALSE; // fail to create } ASSERT(!m_pToolBarButtons); m_pToolBarButtons = pCommandBars->Add(_T("Buttons"), xtpBarTop); if (m_pToolBarButtons) { m_pToolBarButtons->SetBarID(IDR_MAINFRAME); m_pToolBarButtons->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlButton:")); m_pToolBarButtons->GetControls()->Add(xtpControlButton, ID_FILE_NEW); m_pToolBarButtons->GetControls() ->Add(xtpControlButton, ID_FILE_OPEN) ->SetStyle(xtpButtonCaption); m_pToolBarButtons->GetControls() ->Add(xtpControlButton, ID_FILE_SAVE) ->SetStyle(xtpButtonIconAndCaption); } else { TRACE(_T("ERROR: Unable to add Buttons toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarPopups); m_pToolBarPopups = pCommandBars->Add(_T("Popups"), xtpBarTop); if (m_pToolBarPopups) { m_pToolBarPopups->SetBarID(IDR_MAINFRAME + 2); m_pToolBarPopups->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlPopup:")); m_pToolBarPopups->GetControls()->Add(xtpControlPopup, ID_EDIT_PASTE); m_pToolBarPopups->GetControls()->Add(xtpControlPopup, ID_EDIT_COPY)->SetStyle(xtpButtonIcon); m_pToolBarPopups->GetControls() ->Add(xtpControlButtonPopup, ID_EDIT_CUT) ->SetStyle(xtpButtonIconAndCaption); m_pToolBarPopups->GetControls() ->Add(xtpControlSplitButtonPopup, ID_EDIT_SELECT_ALL) ->SetStyle(xtpButtonIconAndCaption); } else { TRACE(_T("ERROR: Unable to add Popups toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarCombo); m_pToolBarCombo = pCommandBars->Add(_T("Combo"), xtpBarTop); if (m_pToolBarCombo) { m_pToolBarCombo->SetBarID(IDR_MAINFRAME + 3); m_pToolBarCombo->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlComboBox:")); m_pToolBarCombo->GetControls()->Add(xtpControlComboBox, ID_FILE_NEW); CXTPControlComboBox* pControlCombo = (CXTPControlComboBox*)m_pToolBarCombo->GetControls() ->Add(xtpControlComboBox, ID_FILE_NEW); pControlCombo->SetDropDownListStyle(); } else { TRACE(_T("ERROR: Unable to add Combo toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarEdit); m_pToolBarEdit = pCommandBars->Add(_T("Edit"), xtpBarTop); if (m_pToolBarEdit) { m_pToolBarEdit->SetBarID(IDR_MAINFRAME + 4); m_pToolBarEdit->GetControls()->Add(xtpControlLabel, 0)->SetCaption(_T("CXTPControlEdit:")); CXTPControlEdit* pControlEdit = (CXTPControlEdit*)m_pToolBarEdit->GetControls()->Add(xtpControlEdit, ID_FILE_NEW); pControlEdit->ShowSpinButtons(TRUE); pControlEdit->SetEditIconId(ID_EDIT_COPY); } else { TRACE(_T("ERROR: Unable to add Edit toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarRadio); m_pToolBarRadio = pCommandBars->Add(_T("Radio"), xtpBarTop); if (m_pToolBarRadio) { m_pToolBarRadio->SetBarID(IDR_MAINFRAME + 5); m_pToolBarRadio->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlRadioButton:")); m_pToolBarRadio->GetControls()->Add(xtpControlRadioButton, 0); } else { TRACE(_T("ERROR: Unable to add Radio toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarCheckBox); m_pToolBarCheckBox = pCommandBars->Add(_T("CheckBox"), xtpBarTop); if (m_pToolBarCheckBox) { m_pToolBarCheckBox->SetBarID(IDR_MAINFRAME + 7); m_pToolBarCheckBox->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlCheckBox:")); m_pToolBarCheckBox->GetControls()->Add(xtpControlCheckBox, 0); } else { TRACE(_T("ERROR: Unable to add CheckBox toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarListBox); m_pToolBarListBox = pCommandBars->Add(_T("ListBox"), xtpBarTop); if (m_pToolBarListBox) { m_pToolBarListBox->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlListBox:")); CXTPControlPopup* pPopup = (CXTPControlPopup*)m_pToolBarListBox->GetControls()->Add(xtpControlPopup, 0); pPopup->SetCaption(_T("ListBox")); CXTPControlListBox* pListBox = (CXTPControlListBox*)pPopup->GetCommandBar()->GetControls()->Add(new CXTPControlListBox, 0); pListBox->GetListCtrl()->AddString(_T("Item 1")); pListBox->GetListCtrl()->AddString(_T("Item 2")); } else { TRACE(_T("ERROR: Unable to add ListBox toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarGallery); m_pToolBarGallery = pCommandBars->Add(_T("Gallery"), xtpBarTop); if (m_pToolBarGallery) { m_pToolBarGallery->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlGallery:")); CXTPControlGalleryItems* pGalleryItems = CXTPControlGalleryItems::CreateItems(pCommandBars, ID_CONTROL_GALLERY); CXTPControlGallery* pControlGallery = (CXTPControlGallery*)m_pToolBarGallery->GetControls()->Add(new CXTPControlGallery(), ID_CONTROL_GALLERY); pGalleryItems->AddItem(_T("Item 1")); pGalleryItems->AddItem(_T("Item 2")); pGalleryItems->AddItem(_T("Item 3")); pGalleryItems->AddItem(_T("Item 4")); pGalleryItems->AddItem(_T("Item 5")); pGalleryItems->SetItemSize(CSize(40, 22)); pControlGallery->SetHeight(XTP_DPI_Y(22)); pControlGallery->SetWidth(XTP_DPI_X(140)); pControlGallery->SetItems(pGalleryItems); pControlGallery->SetFlags(xtpFlagManualUpdate); } else { TRACE(_T("ERROR: Unable to add Gallery toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarColor); m_pToolBarColor = pCommandBars->Add(_T("ColorButton"), xtpBarTop); if (m_pToolBarColor) { m_pToolBarColor->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlColorSelector:")); CXTPControlPopupColor* pControlButtonColor = (CXTPControlPopupColor*)m_pToolBarColor->GetControls()->Add(new CXTPControlPopupColor(), ID_COLOR_FORE); pControlButtonColor->SetColor(0xFF); CXTPPopupToolBar* pPopupToolBar = CXTPPopupToolBar::CreatePopupToolBar(pCommandBars); pControlButtonColor->SetCommandBar(pPopupToolBar); pPopupToolBar->GetControls()->Add(new CXTPControlColorSelector()); pPopupToolBar->InternalRelease(); pControlButtonColor->SetFlags(xtpFlagManualUpdate); pControlButtonColor->SetWidth(XTP_DPI_X(29)); pControlButtonColor->SetHeight(XTP_DPI_Y(18)); } else { TRACE(_T("ERROR: Unable to add ColorButton toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarSlider); m_pToolBarSlider = pCommandBars->Add(_T("Slider"), xtpBarTop); if (m_pToolBarSlider) { m_pToolBarSlider->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlSlider:")); m_pToolBarSlider->GetControls()->Add(new CXTPControlSlider()); } else { TRACE(_T("ERROR: Unable to add Slider toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarScrollBar); m_pToolBarScrollBar = pCommandBars->Add(_T("ScrollBar"), xtpBarTop); if (m_pToolBarScrollBar) { m_pToolBarScrollBar->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlScrollBar:")); m_pToolBarScrollBar->GetControls()->Add(new CXTPControlScrollBar()); CXTPControlScrollBar* pControlScrolBar = (CXTPControlScrollBar*)m_pToolBarScrollBar->GetControls()->Add( new CXTPControlScrollBar()); if (pControlScrolBar) pControlScrolBar->SetScrollBarStyle(xtpScrollStyleSlider); } else { TRACE(_T("ERROR: Unable to add ScrollBar toolbar.\n")); return FALSE; } ASSERT(!m_pToolBarProgress); m_pToolBarProgress = pCommandBars->Add(_T("Progress"), xtpBarTop); if (m_pToolBarProgress) { m_pToolBarProgress->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlProgress:")); CXTPControlProgress* pProgressControl = new CXTPControlProgress(); m_pToolBarProgress->GetControls()->Add(pProgressControl); pProgressControl->SetPos(30); } else { TRACE(_T("ERROR: Unable to add Progress toolbar.\n")); return FALSE; } ASSERT(!m_pWorkspaceBar); m_pWorkspaceBar = pCommandBars->Add(_T("WorkspaceBar"), xtpBarTop); if (m_pWorkspaceBar) { m_pWorkspaceBar->EnableCustomization(FALSE); m_pWorkspaceBar->GetControls() ->Add(xtpControlLabel, 0) ->SetCaption(_T("CXTPControlTabWorkspace:")); CXTPControlTabWorkspace* pControl = (CXTPControlTabWorkspace*)m_pWorkspaceBar->GetControls() ->Add(new CXTPControlTabWorkspace()); m_wndTabClient.Attach(this); m_wndTabClient.SetTabWorkspace(pControl); pControl->GetPaintManager()->m_bFillBackground = FALSE; // pControl->GetPaintManager()->GetAppearanceSet()->m_rcHeaderMargin.top = 1; pControl->GetPaintManager()->SetLayout(xtpTabLayoutSizeToFit); pControl->SetWidth(400); pControl->SetFlags(pControl->GetFlags() | xtpFlagControlStretched); m_pWorkspaceBar->EnableDocking(xtpFlagAlignAny | xtpFlagFloating | xtpFlagStretched); m_wndTabClient.SetFlags(xtpWorkspaceHideAll); m_pWorkspaceBar->SetBarID(IDR_MAINFRAME + 1); m_pWorkspaceBar->GetControls()->CreateOriginalControls(); } else { TRACE(_T("ERROR: Unable to add WorkspaceBar toolbar.\n")); return FALSE; } pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); return UpdateMenuBar(m_nAppliedTheme); } BOOL CMainFrame::UpdateMenuBar(XTPPaintTheme nTheme) { CXTPCommandBars* pCommandBars = GetCommandBars(); if (NULL == pCommandBars) { TRACE0("Failed to create command bars object.\n"); return FALSE; } if (m_pMenuTitleBar) { pCommandBars->Remove(m_pMenuTitleBar); m_pMenuTitleBar = NULL; } if (m_pMenuBar) { pCommandBars->Remove(m_pMenuBar); m_pMenuBar = NULL; } switch (nTheme) { case xtpThemeVisualStudio2019: case xtpThemeVisualStudio2022: { // to set custom title bar icon // int id = 0; // pCommandBars->GetImageManager()->SetVectorIcon(_T("RT_XAML"), // IDR_XAML_SMALL_ICON_NORMAL_BUTTON_HELP, id, 16); m_pMenuTitleBar = pCommandBars->SetMenuTitleBar(_T("Menu Title Bar"), IDR_MAINFRAME // ,id ); if (m_pMenuTitleBar) { m_pMenuTitleBar->SetFlags(xtpFlagIgnoreSetMenuMessage); m_pMenuTitleBar->SetFlags(xtpFlagAlignTop, xtpFlagAlignBottom | xtpFlagAlignLeft | xtpFlagAlignRight | xtpFlagFloating); m_pMenuTitleBar->SetShowGripper(FALSE); m_pMenuTitleBar->RefreshMenu(); } else { TRACE(_T("ERROR: Unable to create Menu Title Bar.\n")); return FALSE; } break; } default: { m_pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); if (m_pMenuBar) { m_pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage); m_pMenuBar->SetFlags(xtpFlagAlignTop | xtpFlagAlignBottom | xtpFlagAlignLeft | xtpFlagAlignRight | xtpFlagFloating, 0); m_pMenuBar->SetShowGripper(TRUE); m_pMenuBar->RefreshMenu(); } else { TRACE(_T("ERROR: Unable to create Menu Bar.\n")); return FALSE; } break; } } m_pToolBarButtons->SetPosition(xtpBarFloating); m_pToolBarEdit->SetPosition(xtpBarFloating); m_pToolBarListBox->SetPosition(xtpBarFloating); m_pToolBarSlider->SetPosition(xtpBarFloating); m_pWorkspaceBar->SetPosition(xtpBarFloating); m_pToolBarButtons->SetPosition(xtpBarTop); m_pToolBarEdit->SetPosition(xtpBarTop); m_pToolBarListBox->SetPosition(xtpBarTop); m_pToolBarSlider->SetPosition(xtpBarTop); m_pWorkspaceBar->SetPosition(xtpBarTop); DockRightOf(m_pToolBarPopups, m_pToolBarButtons); DockRightOf(m_pToolBarCombo, m_pToolBarPopups); DockRightOf(m_pToolBarRadio, m_pToolBarEdit); DockRightOf(m_pToolBarCheckBox, m_pToolBarRadio); DockRightOf(m_pToolBarGallery, m_pToolBarListBox); DockRightOf(m_pToolBarColor, m_pToolBarGallery); DockRightOf(m_pToolBarScrollBar, m_pToolBarSlider); DockRightOf(m_pToolBarProgress, m_pToolBarScrollBar); return TRUE; } void CMainFrame::LoadVectorIcons() { CString type(_T("RT_XAML")); UINT nWidth = 0; nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_NEW, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVEAS, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PASTE, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_REDO_1, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_NEW, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVEAS, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PASTE, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_REDO_1, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_NEW, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVEAS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_REDO_1, ID_EDIT_REDO, 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_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_NEW, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVEAS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_REDO_1, ID_EDIT_REDO, 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_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); } 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() { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); DisableFrameTheme(); UpdateChildrenTheme(); } void CMainFrame::EnableNoStyle(BOOL bEnable /*= TRUE*/) { if (bEnable) { CXTPCommandBarsFrameHook::m_bAllowDwm = FALSE; EnableFrameTheme(GetCommandBars()); } else { DisableFrameTheme(); } UpdateChildrenTheme(); } void CMainFrame::EnableStyleOffice2000(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOfficeXP(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2003(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2007(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice2007); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleRibbon(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice2007); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2007System(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipOffice); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleOffice2013(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); SetTooltipStyle(xtpToolTipOffice2013); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleOffice2016(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); SetTooltipStyle(xtpToolTipOffice2016); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio6(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2005(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2008(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(NULL); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2015(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2017(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2019(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2022(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); SetFrameIcon(CSize(20, 20)); UpdateChildrenTheme(); } else { SetFrameIcon(CSize(16, 16)); DisableStyle(); } } void CMainFrame::EnableStyleWindowsXP(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipLuna); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleWindows7(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipLuna); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleWindows10(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } void CMainFrame::EnableStyleWindows11(BOOL bEnable /*= TRUE*/) { if (bEnable) { GetCommandBars()->SetAllCaps(FALSE); m_wndStatusBar.SetAllCaps(FALSE); SetTooltipStyle(xtpToolTipStandard); EnableFrameTheme(GetCommandBars()); UpdateChildrenTheme(); } else { DisableStyle(); } } XTPControlTheme CMainFrame::GetCustomizeDialogTheme() { XTPControlTheme controlTheme = xtpControlThemeDefault; XTPPaintTheme commandBarsTheme = GetCommandBars()->GetPaintManager()->GetCurrentTheme(); switch (commandBarsTheme) { case xtpThemeResource: controlTheme = xtpControlThemeResource; break; case xtpThemeRibbon: controlTheme = xtpControlThemeResource; break; // case xtpThemeOffice2013: case xtpThemeOffice2016: controlTheme = xtpControlThemeOffice2016; break; case xtpThemeVisualStudio2015: controlTheme = xtpControlThemeVisualStudio2015; break; case xtpThemeVisualStudio2017: controlTheme = xtpControlThemeVisualStudio2017; break; case xtpThemeVisualStudio2019: controlTheme = xtpControlThemeVisualStudio2019; break; case xtpThemeVisualStudio2022: controlTheme = xtpControlThemeVisualStudio2022; break; case xtpThemeNativeWindows10: controlTheme = xtpControlThemeNativeWindows10; break; case xtpThemeNativeWindows11: controlTheme = xtpControlThemeNativeWindows11; break; default: controlTheme = xtpControlThemeDefault; break; } return controlTheme; } void CMainFrame::OnCustomize() { CXTPCustomizeSheet cs(GetCommandBars()); cs.SetTheme(GetCustomizeDialogTheme()); CXTPCustomizeKeyboardPage pageKeyboard(&cs); cs.AddPage(&pageKeyboard); pageKeyboard.AddCategories(IDR_MAINFRAME, TRUE); CXTPCustomizeMenusPage pageMenus(&cs); cs.AddPage(&pageMenus); CXTPCustomizeOptionsPage pageOptions(&cs); cs.AddPage(&pageOptions); CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage(); pCommands->AddCategories(IDR_MAINFRAME, TRUE); pCommands->InsertAllCommandsCategory(); pCommands->InsertBuiltInMenus(IDR_MAINFRAME); pCommands->InsertNewMenuCategory(); cs.SetResizable(TRUE); cs.DoModal(); } void CMainFrame::OnEmptyCommand(UINT nID) { UNREFERENCED_PARAMETER(nID); AfxMessageBox(_T("TODO: Add your own handler")); } void CMainFrame::OnUpdateEmptyCommand(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->Enable(TRUE); } void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { BaseFrame::OnSettingChange(uFlags, lpszSection); } 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::OnOptionsRighttoleft() { if (GetExStyle() & WS_EX_LAYOUTRTL) { GetCommandBars()->SetLayoutRTL(FALSE); ModifyStyleEx(WS_EX_LAYOUTRTL, 0); } else { GetCommandBars()->SetLayoutRTL(TRUE); ModifyStyleEx(0, WS_EX_LAYOUTRTL); } } void CMainFrame::OnUpdateOptionsRighttoleft(CCmdUI* pCmdUI) { if (XTPSystemVersion()->IsLayoutRTLSupported()) { pCmdUI->SetCheck(GetExStyle() & WS_EX_LAYOUTRTL ? TRUE : FALSE); } else { pCmdUI->Enable(FALSE); } } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CMDIFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CMDIFrameWnd::Dump(dc); } #endif //_DEBUG #define xtpThemeDlgRibbon xtpThemeDlgCustom + 1 #define xtpThemeDlgWindowsXP xtpThemeDlgCustom + 2 void CMainFrame::InitThemeDlg() { m_dlgTheme.ExcludeTheme(XTP_EXCLUDE_THEME_CUSTOM | XTP_EXCLUDE_THEME_VISUALSTUDIO2012); m_dlgTheme.Create(IDD_THEME_DIALOG, this); m_dlgTheme.SetTheme(xtpThemeDlgVisualStudio2022, xtpThemeColor2022Blue, xtpThemeAccentUndef, xtpThemeRibbonBackUndef, TRUE); m_dlgTheme.EnableAutoPreview(TRUE); m_dlgTheme.RenameItem(_T("Native Windows"), _T("Native Windows 7")); m_dlgTheme.InsertAfter(_T("Visual Studio 2022"), xtpThemeDlgWindowsXP, _T("Native Windows XP")); m_dlgTheme.InsertAfter(_T("Office 2016"), xtpThemeDlgRibbon, _T("Ribbon")); } void CMainFrame::OnThemeDlg() { m_dlgTheme.ShowWindow(SW_SHOW); } 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 xtpThemeDlgOffice2000: theApp.SetAppTheme(xtpThemeOffice2000); break; case xtpThemeDlgOfficeXP: theApp.SetAppTheme(xtpThemeOfficeXP); break; case xtpThemeDlgOffice2003: theApp.SetAppTheme(xtpThemeOffice2003); break; case xtpThemeDlgWindowsXP: theApp.SetAppTheme(xtpThemeNativeWinXP); break; case xtpThemeDlgNativeWindows: theApp.SetAppTheme(xtpThemeResource, xtpIniWindows7Blue); break; case xtpThemeDlgRibbon: theApp.SetAppTheme(xtpThemeRibbon, xtpIniOffice2007Blue); break; 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 xtpThemeDlgVisualStudio6: theApp.SetAppTheme(xtpThemeVisualStudio6); break; case xtpThemeDlgVisualStudio2005: theApp.SetAppTheme(xtpThemeVisualStudio2005); break; case xtpThemeDlgVisualStudio2008: theApp.SetAppTheme(xtpThemeVisualStudio2008); break; case xtpThemeDlgVisualStudio2010: theApp.SetAppTheme(xtpThemeVisualStudio2010); 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 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; }