// 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 "MultiLangRibbon.h" #include "MainFrm.h" #ifndef WM_DWMCOLORIZATIONCOLORCHANGED # define WM_DWMCOLORIZATIONCOLORCHANGED 0x320 #endif #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() //}}AFX_MSG_MAP ON_COMMAND(ID_OPTIONS_STYLE_THEMEDIALOG, OnThemeDialog) ON_WM_XTP_THEMECHANGED() ON_COMMAND(ID_OPTIONS_FRAMETHEME, OnFrameTheme) ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMETHEME, OnUpdateFrameTheme) ON_COMMAND_RANGE(ID_OPTIONS_FONT_SYSTEM, ID_OPTIONS_FONT_EXTRALARGE, OnOptionsFont) ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FONT_SYSTEM, ID_OPTIONS_FONT_EXTRALARGE, OnUpdateOptionsFont) ON_COMMAND(ID_OPTIONS_FONT_AUTORESIZEICONS, OnAutoResizeIcons) ON_UPDATE_COMMAND_UI(ID_OPTIONS_FONT_AUTORESIZEICONS, OnUpdateAutoResizeIcons) ON_COMMAND(ID_OPTIONS_DPI_ICON_SCALING, OnDpiIconsScaling) ON_UPDATE_COMMAND_UI(ID_OPTIONS_DPI_ICON_SCALING, OnUpdateDpiIconsScaling) ON_MESSAGE(WM_DWMCOLORIZATIONCOLORCHANGED, OnColorizationColorChanged) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here m_bEnableFrameTheme = TRUE; } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } if (!InitCommandBars()) { TRACE0("Failed to create command bar\n"); return -1; } XTPThemeDLL()->SetHandle(xtpIniOffice2016WordColorful); GetCommandBars()->SetTheme(xtpThemeOffice2016); XTPPaintManager()->SetTheme(xtpThemeOffice2016); CreateRibbonBar(); LoadDefaultIcons(); // exclude unused themes. m_dlgTheme.ExcludeTheme( XTP_EXCLUDE_THEME_OFFICE2000 | XTP_EXCLUDE_THEME_OFFICE2003 | XTP_EXCLUDE_THEME_OFFICEXP | XTP_EXCLUDE_THEME_VISUALSTUDIO6 | XTP_EXCLUDE_THEME_VISUALSTUDIO2005 | XTP_EXCLUDE_THEME_VISUALSTUDIO2008 | XTP_EXCLUDE_THEME_VISUALSTUDIO2010 | XTP_EXCLUDE_THEME_VISUALSTUDIO2012 | XTP_EXCLUDE_THEME_CUSTOM); // create theme dialog. VERIFY(m_dlgTheme.Create(IDD_THEME_DIALOG, this)); // set startup theme m_dlgTheme.SetTheme(xtpThemeDlgOffice2016, xtpThemeColor2016Colorful, xtpThemeAccentWord, -1, TRUE); // enable auto preview. m_dlgTheme.EnableAutoPreview(TRUE); CenterWindow(); return 0; } void CMainFrame::LoadDefaultIcons() { CXTPCommandBars* pCommandBars = GetCommandBars(); if (!pCommandBars) return; CXTPImageManager* pImgMgr = pCommandBars->GetImageManager(); if (!pImgMgr) return; pImgMgr->RemoveAll(); CString type(_T("RT_XAML")); // resource type UINT nWidth = 0; nWidth = XTP_DPI_X(16); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_DOCUMENT, ID_FILE_NEW, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE_AS, ID_FILE_SAVE_AS, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_UNDO, ID_EDIT_UNDO, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_REDO, ID_EDIT_REDO, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLOSE_WINDOW, ID_FILE_CLOSE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLIPBOARD_PASTE, ID_EDIT_PASTE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FIND, ID_EDIT_FIND, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SELECT, ID_EDIT_SELECT_ALL, nWidth); nWidth = XTP_DPI_X(32); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_DOCUMENT, ID_FILE_NEW, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE_AS, ID_FILE_SAVE_AS, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_UNDO, ID_EDIT_UNDO, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_REDO, ID_EDIT_REDO, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLOSE_WINDOW, ID_FILE_CLOSE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLIPBOARD_PASTE, ID_EDIT_PASTE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FIND, ID_EDIT_FIND, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SELECT, ID_EDIT_SELECT_ALL, nWidth); // Disabled icons nWidth = XTP_DPI_X(16); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_DOCUMENT, ID_FILE_NEW, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE_AS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_UNDO, ID_EDIT_UNDO, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_REDO, ID_EDIT_REDO, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLOSE_WINDOW, ID_FILE_CLOSE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLIPBOARD_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FIND, ID_EDIT_FIND, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SELECT, ID_EDIT_SELECT_ALL, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_DOCUMENT, ID_FILE_NEW, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE_AS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_UNDO, ID_EDIT_UNDO, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_REDO, ID_EDIT_REDO, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLOSE_WINDOW, ID_FILE_CLOSE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLIPBOARD_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FIND, ID_EDIT_FIND, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SELECT, ID_EDIT_SELECT_ALL, nWidth, xtpImageDisabled); UINT uiFlagIcons[] = { ID_LANGUAGE_ENGLISH, ID_LANGUAGE_GERMAN, ID_LANGUAGE_JAPANESE, ID_LANGUAGE_ARABIC, ID_LANGUAGE_RUSSIAN }; pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_16, uiFlagIcons, _countof(uiFlagIcons), CSize(16, 16)); pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_24, uiFlagIcons, _countof(uiFlagIcons), CSize(24, 24)); pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_32, uiFlagIcons, _countof(uiFlagIcons), CSize(32, 32)); pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_40, uiFlagIcons, _countof(uiFlagIcons), CSize(40, 40)); pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_48, uiFlagIcons, _countof(uiFlagIcons), CSize(48, 48)); pCommandBars->GetImageManager()->SetIcons(PNG_FLAG_64, uiFlagIcons, _countof(uiFlagIcons), CSize(64, 64)); GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons = TRUE; } BOOL CMainFrame::CreateRibbonBar() { CMenu menu; menu.Attach(::GetMenu(m_hWnd)); SetMenu(NULL); CXTPCommandBars* pCommandBars = GetCommandBars(); if (!pCommandBars) { return FALSE; } pCommandBars->RemoveAll(); CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, pCommandBars->Add(_T("The Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar))); if (!pRibbonBar) { return FALSE; } CString str; XTPResourceManager()->LoadString(&str, ID_TAB_DEFAULT); CXTPRibbonTab* pTab1 = pRibbonBar->AddTab(str); if (pTab1) { XTPResourceManager()->LoadString(&str, ID_GROUP_FILE); CXTPRibbonGroup* pGroupFile = pTab1->AddGroup(str); if (pGroupFile) { pGroupFile->Add(xtpControlButton, ID_FILE_NEW); pGroupFile->Add(xtpControlButton, ID_FILE_OPEN); pGroupFile->Add(xtpControlButton, ID_FILE_CLOSE); pGroupFile->Add(xtpControlButton, ID_FILE_SAVE); pGroupFile->Add(xtpControlButton, ID_FILE_SAVE_AS); pGroupFile->Add(xtpControlButton, ID_FILE_PRINT); } XTPResourceManager()->LoadString(&str, ID_GROUP_EDIT); CXTPRibbonGroup* pGroupEdit = pTab1->AddGroup(str); if (pGroupEdit) { pGroupEdit->Add(xtpControlButton, ID_EDIT_COPY); pGroupEdit->Add(xtpControlButton, ID_EDIT_CUT); pGroupEdit->Add(xtpControlButton, ID_EDIT_PASTE); pGroupEdit->Add(xtpControlButton, ID_EDIT_FIND); pGroupEdit->Add(xtpControlButton, ID_EDIT_REPLACE); pGroupEdit->Add(xtpControlButton, ID_EDIT_SELECT_ALL); } XTPResourceManager()->LoadString(&str, ID_GROUP_LANGUAGE); CXTPRibbonGroup* pGroupLanguage = pTab1->AddGroup(str); if (pGroupLanguage) { pGroupLanguage->Add(xtpControlButton, ID_LANGUAGE_ENGLISH); pGroupLanguage->Add(xtpControlButton, ID_LANGUAGE_GERMAN); pGroupLanguage->Add(xtpControlButton, ID_LANGUAGE_JAPANESE); pGroupLanguage->Add(xtpControlButton, ID_LANGUAGE_ARABIC); pGroupLanguage->Add(xtpControlButton, ID_LANGUAGE_RUSSIAN); } } CXTPControlPopup* pControlOptions = DYNAMIC_DOWNCAST(CXTPControlPopup, 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 = pRibbonBar->GetControls()->Add(xtpControlButton, ID_APP_ABOUT); if (pControlAbout) pControlAbout->SetFlags(xtpFlagRightAlign); pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_SAVE); pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_EDIT_UNDO); pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_EDIT_REDO); pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, ID_FILE_PRINT); pRibbonBar->GetQuickAccessControls()->CreateOriginalControls(); pRibbonBar->EnableFrameTheme(m_bEnableFrameTheme); GetCommandBars()->GetPaintManager()->RefreshMetrics(); GetCommandBars()->RedrawCommandBars(); return TRUE; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if (!CFrameWnd::PreCreateWindow(cs)) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers void CMainFrame::OnThemeDialog() { m_dlgTheme.ShowWindow(SW_SHOW); } LRESULT CMainFrame::OnThemeChanged(WPARAM wParam, LPARAM lParam) { THEME_COLOR* pThemeColor = reinterpret_cast(lParam); int nTheme = pThemeColor->nTheme; int nColor = pThemeColor->nColor; int nAccent = pThemeColor->nAccent; #ifdef _XTP_INCLUDE_RIBBON int nBack = pThemeColor->nBack; #endif XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast(pThemeColor->nAccent)); XTPGetApplication()->SetAmbientProperty(xtpApplicationUseSystemAccentColor, static_cast(pThemeColor->bUseSystemAccent)); switch (nTheme) { case xtpThemeDlgNativeWindows: { XTPThemeDLL()->SetHandle(xtpIniWindows7Blue); GetCommandBars()->SetTheme(xtpThemeRibbon); XTPPaintManager()->SetTheme(xtpThemeRibbon); } break; case xtpThemeDlgOffice2007: { switch (nColor) { case xtpThemeColor2007Blue: XTPThemeDLL()->SetHandle(xtpIniOffice2007Blue); break; case xtpThemeColor2007Silver: XTPThemeDLL()->SetHandle(xtpIniOffice2007Silver); break; case xtpThemeColor2007Black: XTPThemeDLL()->SetHandle(xtpIniOffice2007Black); break; case xtpThemeColor2007Aqua: XTPThemeDLL()->SetHandle(xtpIniOffice2007Aqua); break; case xtpThemeColor2007System: XTPThemeDLL()->SetHandle(_T("")); break; } XTPPaintTheme theme = (nColor == xtpThemeColor2007System ? xtpThemeOfficeXP : xtpThemeRibbon); GetCommandBars()->SetTheme(theme); XTPPaintManager()->SetTheme(theme); } break; case xtpThemeDlgOffice2010: { switch (nColor) { case xtpThemeColor2010Blue: XTPThemeDLL()->SetHandle(xtpIniOffice2010Blue); break; case xtpThemeColor2010Silver: XTPThemeDLL()->SetHandle(xtpIniOffice2010Silver); break; case xtpThemeColor2010Black: XTPThemeDLL()->SetHandle(xtpIniOffice2010Black); break; } GetCommandBars()->SetTheme(xtpThemeRibbon); XTPPaintManager()->SetTheme(xtpThemeRibbon); } break; case xtpThemeDlgOffice2013: { switch (nColor) { case xtpThemeColor2013White: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2013Access); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2013Excel); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2013OneNote); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2013Outlook); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2013PowerPoint); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2013Publisher); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2013Word); break; } } break; case xtpThemeColor2013GrayLight: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2013AccessGrayLight); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2013ExcelGrayLight); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2013OneNoteGrayLight); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2013OutlookGrayLight); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2013PowerPointGrayLight); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2013PublisherGrayLight); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2013WordGrayLight); break; } } break; case xtpThemeColor2013GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2013AccessGrayDark); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2013ExcelGrayDark); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2013OneNoteGrayDark); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2013OutlookGrayDark); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2013PowerPointGrayDark); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2013PublisherGrayDark); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2013WordGrayDark); break; } } break; } // BackImage GetCommandBars()->SetTheme(xtpThemeOffice2013); XTPPaintManager()->SetTheme(xtpThemeOffice2013); } break; case xtpThemeDlgOffice2016: { switch (nColor) { case xtpThemeColor2016Black: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2016AccessBlack); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2016ExcelBlack); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2016OneNoteBlack); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2016OutlookBlack); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2016PowerPointBlack); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2016PublisherBlack); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2016WordBlack); break; } } break; case xtpThemeColor2016White: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2016AccessWhite); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2016ExcelWhite); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2016OneNoteWhite); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2016OutlookWhite); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2016PowerPointWhite); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2016PublisherWhite); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2016WordWhite); break; } } break; case xtpThemeColor2016Colorful: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2016AccessColorful); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2016ExcelColorful); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2016OneNoteColorful); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2016OutlookColorful); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2016PowerPointColorful); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2016PublisherColorful); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2016WordColorful); break; } } break; case xtpThemeColor2016GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: XTPThemeDLL()->SetHandle(xtpIniOffice2016AccessDarkGray); break; case xtpThemeAccentExcel: XTPThemeDLL()->SetHandle(xtpIniOffice2016ExcelDarkGray); break; case xtpThemeAccentOneNote: XTPThemeDLL()->SetHandle(xtpIniOffice2016OneNoteDarkGray); break; case xtpThemeAccentOutlook: XTPThemeDLL()->SetHandle(xtpIniOffice2016OutlookDarkGray); break; case xtpThemeAccentPowerPoint: XTPThemeDLL()->SetHandle(xtpIniOffice2016PowerPointDarkGray); break; case xtpThemeAccentPublisher: XTPThemeDLL()->SetHandle(xtpIniOffice2016PublisherDarkGray); break; case xtpThemeAccentWord: XTPThemeDLL()->SetHandle(xtpIniOffice2016WordDarkGray); break; } } break; } GetCommandBars()->SetTheme(xtpThemeOffice2016); XTPPaintManager()->SetTheme(xtpThemeOffice2016); } break; case xtpThemeDlgVisualStudio2015: { switch (nColor) { case xtpThemeColor2015Blue: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Blue); break; case xtpThemeColor2015Dark: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Dark); break; case xtpThemeColor2015Light: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Light); break; } GetCommandBars()->SetTheme(xtpThemeVisualStudio2015); XTPPaintManager()->SetTheme(xtpThemeVisualStudio2015); } break; case xtpThemeDlgVisualStudio2017: { switch (nColor) { case xtpThemeColor2017Blue: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2017Blue); break; case xtpThemeColor2017BlueExtra: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2017BlueExtra); break; case xtpThemeColor2017Dark: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2017Dark); break; case xtpThemeColor2017Light: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2017Light); break; } GetCommandBars()->SetTheme(xtpThemeVisualStudio2017); XTPPaintManager()->SetTheme(xtpThemeVisualStudio2017); } break; case xtpThemeDlgVisualStudio2019: { switch (nColor) { case xtpThemeColor2019Blue: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2019Blue); break; case xtpThemeColor2019BlueExtra: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2019BlueExtra); break; case xtpThemeColor2019Dark: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2019Dark); break; case xtpThemeColor2019Light: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2019Light); break; } GetCommandBars()->SetTheme(xtpThemeVisualStudio2019); XTPPaintManager()->SetTheme(xtpThemeVisualStudio2019); } break; case xtpThemeDlgVisualStudio2022: { switch (nColor) { case xtpThemeColor2022Blue: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2022Blue); break; case xtpThemeColor2022BlueExtra: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2022BlueExtra); break; case xtpThemeColor2022Dark: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2022Dark); break; case xtpThemeColor2022Light: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2022Light); break; } GetCommandBars()->SetTheme(xtpThemeVisualStudio2022); XTPPaintManager()->SetTheme(xtpThemeVisualStudio2022); } break; case xtpThemeDlgNativeWindows10: { switch (nColor) { case xtpThemeColorWindows10Light: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); XTPThemeDLL()->SetHandle(xtpIniWindows10Light); break; case xtpThemeColorWindows10Dark: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); XTPThemeDLL()->SetHandle(xtpIniWindows10Dark); break; } GetCommandBars()->SetTheme(xtpThemeNativeWindows10); XTPPaintManager()->SetTheme(xtpThemeNativeWindows10); } break; case xtpThemeDlgNativeWindows11: { switch (nColor) { case xtpThemeColorWindows11Light: XTPThemeDLL()->SetHandle(xtpIniWindows11Light); break; case xtpThemeColorWindows11Dark: XTPThemeDLL()->SetHandle(xtpIniWindows11Dark); break; } GetCommandBars()->SetTheme(xtpThemeNativeWindows11); XTPPaintManager()->SetTheme(xtpThemeNativeWindows11); } break; } CXTPCommandBars* pCommandBars = GetCommandBars(); _ASSERTE(NULL != pCommandBars); CXTPRibbonBar* pRibbonBar = STATIC_DOWNCAST(CXTPRibbonBar, pCommandBars->GetMenuBar()); pRibbonBar->EnableFrameTheme(m_bEnableFrameTheme); _ASSERTE(pCommandBars->GetPaintManager()); _ASSERTE(pCommandBars->GetCommandBarsOptions()); _ASSERTE(pCommandBars->GetToolTipContext()); pCommandBars->SetAllCaps(nTheme == xtpThemeOffice2013 ? TRUE : FALSE); pCommandBars->GetStatusBar()->SetAllCaps(nTheme == xtpThemeOffice2013 ? TRUE : FALSE); pCommandBars->GetPaintManager()->m_bAutoResizeIcons = TRUE; pCommandBars->GetPaintManager()->m_bEnableAnimation = TRUE; pCommandBars->GetPaintManager()->RefreshMetrics(); pCommandBars->UpdateCommandBars(); pCommandBars->RedrawCommandBars(); SendMessageToDescendants(WM_XTP_THEMECHANGED); SendMessage(WM_NCPAINT); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE); return 0; } LRESULT CMainFrame::OnColorizationColorChanged(WPARAM /*wParam*/, LPARAM /*lParam*/) { XTPGetApplication()->TriggerAmbientPropertyUpdate(xtpApplicationAccentColor); RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_FRAME); return Default(); } void CMainFrame::OnFrameTheme() { ShowWindow(SW_NORMAL); CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetAt(0)); _ASSERTE(pRibbonBar); CXTPWindowRect rc(this); rc.top += (m_bEnableFrameTheme ? -1 : +1) * GetSystemMetrics(SM_CYCAPTION); MoveWindow(rc); m_bEnableFrameTheme = !m_bEnableFrameTheme; pRibbonBar->EnableFrameTheme(m_bEnableFrameTheme); } void CMainFrame::OnUpdateFrameTheme(CCmdUI* pCmdUI) { CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetAt(0)); _ASSERTE(pRibbonBar); pCmdUI->SetCheck(pRibbonBar->IsFrameThemeEnabled() ? TRUE : FALSE); } int nFonts[] = { 0, 11, 13, 16 }; void CMainFrame::OnOptionsFont(UINT nID) { int nFontHeight = XTP_DPI_Y(nFonts[nID - ID_OPTIONS_FONT_SYSTEM]); CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetAt(0)); _ASSERTE(pRibbonBar); pRibbonBar->SetFontHeight(nFontHeight); } void CMainFrame::OnUpdateOptionsFont(CCmdUI* pCmdUI) { int nFontHeight = XTP_DPI_Y(nFonts[pCmdUI->m_nID - ID_OPTIONS_FONT_SYSTEM]); CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetAt(0)); _ASSERTE(pRibbonBar); pCmdUI->SetCheck(pRibbonBar->GetFontHeight() == nFontHeight ? TRUE : FALSE); } void CMainFrame::OnAutoResizeIcons() { GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons ^= 1; GetCommandBars()->RedrawCommandBars(); } void CMainFrame::OnUpdateAutoResizeIcons(CCmdUI* pCmdUI) { pCmdUI->SetCheck(GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons); } void CMainFrame::OnDpiIconsScaling() { CXTPCommandBars* pCommandBars = GetCommandBars(); _ASSERTE(NULL != pCommandBars); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); _ASSERTE(NULL != pOptions); pOptions->EnableDpiBitmapScaling(!pOptions->IsDpiBitmapScalingEnabled()); pCommandBars->RedrawCommandBars(); } void CMainFrame::OnUpdateDpiIconsScaling(CCmdUI* pCmdUI) { CXTPCommandBars* pCommandBars = GetCommandBars(); _ASSERTE(NULL != pCommandBars); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); _ASSERTE(NULL != pOptions); pCmdUI->SetCheck(pOptions->IsDpiBitmapScalingEnabled()); } void CMainFrame::SetRightToLeft(BOOL value) { if (value) { GetCommandBars()->SetLayoutRTL(TRUE); ModifyStyleEx(0, WS_EX_LAYOUTRTL); } else { GetCommandBars()->SetLayoutRTL(FALSE); ModifyStyleEx(WS_EX_LAYOUTRTL, 0); } RecalcLayout(FALSE); }