// 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 "MultiLangCommandBars.h" #include "MainFrm.h" #ifndef WM_DWMCOLORIZATIONCOLORCHANGED # define WM_DWMCOLORIZATIONCOLORCHANGED 0x320 #endif extern CMultiLangCommandBarsApp theApp; #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_WM_CLOSE() //}}AFX_MSG_MAP ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp) ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder) // menu and command bar customization. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize) ON_UPDATE_COMMAND_UI_RANGE(ID_POPUP_FILE, ID_POPUP_HELP, OnUpdatePopup) ON_WM_XTP_THEMECHANGED() ON_COMMAND(ID_THEME_THEMEDIALOG, OnThemeDialog) 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() { } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) return -1; if (!InitCommandBars()) return -1; GetCommandBars()->EnableActions(); SetCommandBarMenu(); XTPThemeDLL()->SetHandle(xtpIniOffice2016WordColorful); GetCommandBars()->SetTheme(xtpThemeOffice2016); XTPPaintManager()->SetTheme(xtpThemeOffice2016); GetCommandBars()->EnableFrameTheme(TRUE); GetCommandBars()->GetPaintManager()->m_bAutoResizeIcons = TRUE; // Load the previous state for toolbars and menus. LoadCommandBars(_T("CommandBars2")); // exclude unused themes. m_dlgTheme.ExcludeTheme(XTP_EXCLUDE_THEME_VISUALSTUDIO2012 | XTP_EXCLUDE_THEME_CUSTOM); // set startup theme m_dlgTheme.SetTheme(xtpThemeDlgOffice2016, xtpThemeColor2016Colorful, xtpThemeAccentWord); // create theme dialog. VERIFY(m_dlgTheme.Create(IDD_THEME_DIALOG, this)); // enable auto preview. m_dlgTheme.EnableAutoPreview(TRUE); return 0; } BOOL CMainFrame::SetCommandBarMenu() { CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars) { CString strMenubar, strStandart; strMenubar.LoadString(IDS_MENUBAR); strStandart.LoadString(IDS_STANDARD); CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(strMenubar, IDR_MAINFRAME); if (pMenuBar == NULL) { return FALSE; } CXTPToolBar* pToolBar = pCommandBars->Add(strStandart, xtpBarTop); if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME)) { return FALSE; } CMenu menu; if (menu.LoadMenu(IDR_SCRIBBTYPE)) { pCommandBars->GetActions()->CreateFromMenu(&menu); return TRUE; } } return FALSE; } void CMainFrame::ResetCommandBars() { m_bInRecalcLayout = TRUE; CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars) { CMenu menu; XTPResourceManager()->LoadMenu(&menu, IDR_SCRIBBTYPE); pCommandBars->GetActions()->CreateFromMenu(&menu); CString strTitle; XTPResourceManager()->LoadString(&strTitle, IDS_MENUBAR); pCommandBars->GetMenuBar()->SetTitle(strTitle); XTPResourceManager()->LoadString(&strTitle, IDS_STANDARD); pCommandBars->GetToolBar(IDR_MAINFRAME)->SetTitle(strTitle); m_bInRecalcLayout = FALSE; RecalcLayout(); AfxGetApp()->OnIdle(0); UpdateWindow(); } } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CMDIFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CMDIFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers 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() { // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars != NULL) { // Instanciate the customize dialog object. CXTPCustomizeSheet dlg(pCommandBars); dlg.SetTheme(GetCustomizeDialogTheme()); // Add the options page to the customize dialog. CXTPCustomizeOptionsPage pageOptions(&dlg); dlg.AddPage(&pageOptions); // Add the commands page to the customize dialog. CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage(); pCommands->AddCategories(IDR_SCRIBBTYPE); // Use the command bar manager to initialize the customize dialog. pCommands->InsertAllCommandsCategory(); pCommands->InsertBuiltInMenus(IDR_SCRIBBTYPE); pCommands->InsertNewMenuCategory(); // Dispaly the dialog. dlg.DoModal(); } } void CMainFrame::OnClose() { // Save the current state for toolbars and menus. SaveCommandBars(_T("CommandBars2")); CMDIFrameWnd::OnClose(); } void CMainFrame::OnUpdatePopup(CCmdUI* pCmdUI) { pCmdUI->Enable(); } 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: XTPPaintManager()->SetTheme(xtpThemeNativeWinXP); GetCommandBars()->SetTheme(xtpThemeNativeWinXP); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgOffice2000: XTPPaintManager()->SetTheme(xtpThemeOffice2000); GetCommandBars()->SetTheme(xtpThemeOffice2000); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgOfficeXP: XTPPaintManager()->SetTheme(xtpThemeOfficeXP); GetCommandBars()->SetTheme(xtpThemeOfficeXP); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgOffice2003: XTPPaintManager()->SetTheme(xtpThemeOffice2003); GetCommandBars()->SetTheme(xtpThemeOffice2003); GetCommandBars()->EnableFrameTheme(FALSE); 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 : xtpThemeOffice2007); XTPPaintManager()->SetTheme(theme); GetCommandBars()->SetTheme(theme); GetCommandBars()->EnableFrameTheme(TRUE); } break; case xtpThemeDlgOffice2010: { switch (nColor) { case xtpThemeColor2010Blue: XTPThemeDLL()->SetHandle(xtpIniOffice2010Blue); break; case xtpThemeColor2010Silver: XTPThemeDLL()->SetHandle(xtpIniOffice2010Silver); break; case xtpThemeColor2010Black: XTPThemeDLL()->SetHandle(xtpIniOffice2010Black); break; } XTPPaintManager()->SetTheme(xtpThemeRibbon); GetCommandBars()->SetTheme(xtpThemeRibbon); GetCommandBars()->EnableFrameTheme(TRUE); } 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; } XTPPaintManager()->SetTheme(xtpThemeOffice2013); GetCommandBars()->SetTheme(xtpThemeOffice2013); GetCommandBars()->EnableFrameTheme(TRUE); } 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); GetCommandBars()->EnableFrameTheme(TRUE); } break; case xtpThemeDlgVisualStudio6: XTPPaintManager()->SetTheme(xtpThemeVisualStudio6); GetCommandBars()->SetTheme(xtpThemeVisualStudio6); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgVisualStudio2005: XTPPaintManager()->SetTheme(xtpThemeVisualStudio2005); GetCommandBars()->SetTheme(xtpThemeVisualStudio2005); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgVisualStudio2008: XTPPaintManager()->SetTheme(xtpThemeVisualStudio2008); GetCommandBars()->SetTheme(xtpThemeVisualStudio2008); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgVisualStudio2010: XTPPaintManager()->SetTheme(xtpThemeVisualStudio2010); GetCommandBars()->SetTheme(xtpThemeVisualStudio2010); GetCommandBars()->EnableFrameTheme(FALSE); break; case xtpThemeDlgVisualStudio2015: { switch (nColor) { case xtpThemeColor2015Blue: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Blue); break; case xtpThemeColor2015Dark: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Dark); break; case xtpThemeColor2015Light: XTPThemeDLL()->SetHandle(xtpIniVisualStudio2015Light); break; } XTPPaintManager()->SetTheme(xtpThemeVisualStudio2015); GetCommandBars()->SetTheme(xtpThemeVisualStudio2015); GetCommandBars()->EnableFrameTheme(TRUE); } 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; } XTPPaintManager()->SetTheme(xtpThemeVisualStudio2017); GetCommandBars()->SetTheme(xtpThemeVisualStudio2017); GetCommandBars()->EnableFrameTheme(TRUE); } 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; } XTPPaintManager()->SetTheme(xtpThemeVisualStudio2019); GetCommandBars()->SetTheme(xtpThemeVisualStudio2019); GetCommandBars()->EnableFrameTheme(TRUE); } 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; } XTPPaintManager()->SetTheme(xtpThemeVisualStudio2022); GetCommandBars()->SetTheme(xtpThemeVisualStudio2022); GetCommandBars()->EnableFrameTheme(TRUE); } 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; } XTPPaintManager()->SetTheme(xtpThemeNativeWindows10); GetCommandBars()->SetTheme(xtpThemeNativeWindows10); GetCommandBars()->EnableFrameTheme(TRUE); } break; case xtpThemeDlgNativeWindows11: { switch (nColor) { case xtpThemeColorWindows11Light: XTPThemeDLL()->SetHandle(xtpIniWindows11Light); break; case xtpThemeColorWindows11Dark: XTPThemeDLL()->SetHandle(xtpIniWindows11Dark); break; } XTPPaintManager()->SetTheme(xtpThemeNativeWindows11); GetCommandBars()->SetTheme(xtpThemeNativeWindows11); GetCommandBars()->EnableFrameTheme(TRUE); } break; } UpdateMDIChildrenTheme(); return 0; } LRESULT CMainFrame::OnColorizationColorChanged(WPARAM /*wParam*/, LPARAM /*lParam*/) { XTPGetApplication()->TriggerAmbientPropertyUpdate(xtpApplicationAccentColor); RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_FRAME); return Default(); }