// 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 "GUI_VisualStudio.h" #include "ChildFrm.h" #include "MainFrm.h" #include "GUI_VisualStudioDoc.h" #include "GUI_VisualStudioView.h" #ifdef _DEBUG # define new DEBUG_NEW #endif IMPLEMENT_DYNCREATE(CMainFrame, CXTPMDIFrameWndEx) BEGIN_MESSAGE_MAP(CMainFrame, CXTPMDIFrameWndEx) ON_WM_CREATE() ON_WM_CLOSE() ON_WM_ACTIVATE() ON_WM_DESTROY() ON_WM_GETMINMAXINFO() ON_WM_SETTINGCHANGE() ON_XTP_CREATECONTROL() ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify) ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize) ON_COMMAND(ID_VIEW_MESSAGE_BAR, OnViewMessageBar) ON_UPDATE_COMMAND_UI(ID_VIEW_MESSAGE_BAR, OnUpdateViewMessageBar) ON_COMMAND_RANGE(ID_FILE_NEW_PROJECT, ID_HELP_SEARCH, OnEmptyCommand) ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_NEW_PROJECT, ID_HELP_SEARCH, OnUpdateEmptyCommand) ON_WM_XTP_THEMECHANGED() ON_COMMAND(ID_THEME, OnThemeDlg) ON_COMMAND(ID_WINDOW_AUTOHIDEALL, OnWindowAutohideall) ON_COMMAND(ID_WINDOW_CLOSE_ALL, OnWindowCloseAll) ON_COMMAND(ID_WINDOW_MORE, OnWindowMore) ON_COMMAND_RANGE(ID_WEBBROWSER_BACK, ID_WEBBROWSER_FONT, OnEmptyCommand) ON_UPDATE_COMMAND_UI_RANGE(ID_WEBBROWSER_BACK, ID_WEBBROWSER_FONT, OnUpdateEmptyCommand) ON_COMMAND_RANGE(ID_STATE_COLOR_DEFAULT, ID_STATE_COLOR_BLUE, OnStateColor) ON_UPDATE_COMMAND_UI_RANGE(ID_STATE_COLOR_DEFAULT, ID_STATE_COLOR_BLUE, OnUpdateStateColor) ON_COMMAND(ID_VIEW_FULLSCREEN, OnFullScreen) ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateFullScreen) ON_XTP_EXECUTE(ID_EDIT_CONFIGURATION, OnEditConfiguration) ON_UPDATE_COMMAND_UI(ID_EDIT_CONFIGURATION, OnUpdateEditConfiguration) ON_XTP_EXECUTE(ID_EDIT_PLATFORM, OnEditPlatform) ON_UPDATE_COMMAND_UI(ID_EDIT_PLATFORM, OnUpdateEditPlatform) ON_MESSAGE(WM_XTP_TABTODOCKPANE, OnTabToDockpane) ON_COMMAND_RANGE(ID_VIEW_SOLUTIONEXPLORER, ID_VIEW_OUTPUT, OnView) ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_SOLUTIONEXPLORER, ID_VIEW_OUTPUT, OnUpdateView) END_MESSAGE_MAP() CMainFrame::CMainFrame() : m_bThemeApplied(FALSE) , m_nAppliedTheme(xtpThemeNone) , m_nStateColor(ID_STATE_COLOR_DEFAULT) , m_pMenuTitleBar(NULL) , m_pMenuBar(NULL) , m_pToolBarStandart(NULL) , m_pToolBarWeb(NULL) , m_pToolBarState(NULL) , m_pFullScreen(NULL) , m_nConfiguration(1) , m_nPlatform(0) , m_bFullScreen(FALSE) , m_pFullScreenLayout(NULL) { // get path of executable TCHAR szBuff[_MAX_PATH]; VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuff, _MAX_PATH)); LPTSTR lpszExt = _tcsrchr(szBuff, '.'); lstrcpy(lpszExt, _T(".xml")); m_strIniFileName = szBuff; } CMainFrame::~CMainFrame() { if (m_pFullScreenLayout) { delete m_pFullScreenLayout; } } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) { TRACE(_T("ERROR: Failed to create main frame.\n")); return -1; } // Default menu has to be disabled so that it does not overlap CommandBars SetMenu(NULL); if (!CreateStatusBar()) { TRACE(_T("ERROR: Failed to create the status bar.\n")); return -1; } if (!InitCommandBars()) { TRACE(_T("ERROR: Failed to initialize command bars.\n")); return -1; } if (!CreateToolbars()) { TRACE(_T("ERROR: Failed to create toolbars.\n")); return -1; } if (!CreateDockingPanes()) { TRACE(_T("ERROR: Failed to create docking panes.\n")); return -1; } if (!CreateMessageBar()) { TRACE(_T("ERROR: Failed to create the message bar.\n")); return -1; } if (!CreateTabClient()) { TRACE(_T("ERROR: Failed to create tab client.\n")); return -1; } ModifyStyle(0, FWS_PREFIXTITLE); InitTooltips(); InitThemeDlg(); InitLayout(); CenterWindow(); return 0; } void CMainFrame::OnClose() { // CXTPPropExchangeIniFile px(FALSE, 0, _T("Settings")); // To serialize to ini file CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings")); // To serialize to XML file if (px.OnBeforeExchange()) { CXTPPropExchangeSection pxTaskPanel(px.GetSection(_T("TaskPanel"))); m_wndToolbox.DoPropExchange(&pxTaskPanel); // Reset Full Screen Mode if (m_bFullScreen) { OnFullScreen(); } CXTPPropExchangeSection pxNormalLayout(px.GetSection(_T("NormalLayout"))); ExchangeLayout(&pxNormalLayout); px.PutSection(m_pFullScreenLayout); px.SaveToFile(m_strIniFileName); } CXTPMDIFrameWndEx::OnClose(); } void CMainFrame::OnDestroy() { CXTPMDIFrameWndEx::OnDestroy(); GetTabClientWnd()->Detach(); } void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { lpMMI->ptMinTrackSize.x = XTP_DPI_X(1280); lpMMI->ptMinTrackSize.y = XTP_DPI_Y(720); CXTPMDIFrameWndEx::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_PROJECT: lpCreateControl->controlType = xtpControlSplitButtonPopup; return TRUE; case ID_PROJECT_ADDNEWITEM: lpCreateControl->controlType = xtpControlSplitButtonPopup; return TRUE; case ID_EDIT_FIND_EX: { CXTPControlComboBox* pComboFind = (CXTPControlComboBox*) CXTPControlComboBox::CreateObject(); ASSERT_VALID(pComboFind); // pComboFind->ModifyListBoxStyle(0, LBS_OWNERDRAWFIXED | LBS_HASSTRINGS); // pComboFind->SetFlags(xtpFlagManualUpdate); pComboFind->SetDropDownListStyle(); pComboFind->AddString(_T("Line1")); pComboFind->AddString(_T("Line2")); pComboFind->AddString(_T("Line3")); pComboFind->SetWidth(XTP_DPI_X(180)); pComboFind->SetCaption(_T("Find")); pComboFind->SetStyle(xtpComboLabel); pComboFind->SetEditText(_T("Line1")); lpCreateControl->pControl = pComboFind; return TRUE; } case IDR_TOOLBAR_WEB: // if (ID_GOTO_URL == lpCreateControl->nID) { CXTPControlComboBox* pComboUrl = (CXTPControlComboBox*) CXTPControlComboBox::CreateObject(); ASSERT_VALID(pComboUrl); // pComboUrl->ModifyListBoxStyle(0, LBS_OWNERDRAWFIXED | LBS_HASSTRINGS); pComboUrl->AddString(_T("http://www.codejock.com")); pComboUrl->AddString(_T("http://forum.codejock.com")); pComboUrl->SetWidth(XTP_DPI_X(200)); pComboUrl->SetDropDownWidth(XTP_DPI_X(300)); pComboUrl->SetDropDownListStyle(); pComboUrl->SetFlags(xtpFlagManualUpdate); pComboUrl->SetEditText(_T("http://www.codejock.com")); pComboUrl->EnableShellAutoComplete(); lpCreateControl->pControl = pComboUrl; return TRUE; } case ID_EDIT_CONFIGURATION: { CXTPControlComboBox* pComboTarget = new CXTPControlComboBox(GetCommandBars()); pComboTarget->ModifyListBoxStyle(0, LBS_OWNERDRAWFIXED | LBS_HASSTRINGS); pComboTarget->SetFlags(xtpFlagManualUpdate); pComboTarget->AddString(_T("Debug")); pComboTarget->AddString(_T("Release")); pComboTarget->AddString(_T("Configuration Manager...")); pComboTarget->SetDropDownWidth(XTP_DPI_X(150)); pComboTarget->SetDropDownListStyle(); pComboTarget->SetEditText(_T("Debug")); lpCreateControl->pControl = pComboTarget; return TRUE; } case ID_EDIT_PLATFORM: { CXTPControlComboBox* pComboState = new CXTPControlComboBox(GetCommandBars()); pComboState->ModifyListBoxStyle(0, LBS_OWNERDRAWFIXED | LBS_HASSTRINGS); pComboState->SetFlags(xtpFlagManualUpdate); pComboState->AddString(_T("x64")); pComboState->AddString(_T("x86")); pComboState->AddString(_T("Configuration Manager...")); pComboState->SetDropDownWidth(XTP_DPI_X(150)); pComboState->SetDropDownListStyle(); pComboState->SetCurSel(0); lpCreateControl->pControl = pComboState; return TRUE; } case ID_VIEW_FULLSCREEN: { lpCreateControl->buttonStyle = xtpButtonIconAndCaption; return TRUE; } break; } } return FALSE; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if (!CXTPMDIFrameWndEx::PreCreateWindow(cs)) return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | FWS_ADDTOTITLE; cs.lpszClass = _T("XTPMainFrame"); CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); return TRUE; } void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState) { GetCommandBars()->OnSetPreviewMode(bPreview); GetTabClientWnd()->ShowWorkspace(!bPreview); GetDockingPaneManager()->OnSetPreviewMode(bPreview); CXTPMDIFrameWndEx::OnSetPreviewMode(bPreview, pState); } CXTPDockingPaneManager* CMainFrame::GetDockingPaneManager() { return &m_wndPaneManager; } CXTPTabClientWnd* CMainFrame::GetTabClientWnd() { return &m_wndTabClient; } 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(); ASSERT_VALID(pCommandBars); m_pToolBarStandart = pCommandBars->Add(_T("Standard"), xtpBarTop); if (NULL == m_pToolBarStandart || !m_pToolBarStandart->LoadToolBar(IDR_MAINFRAME)) { TRACE(_T("ERROR: Unable to add Standard toolbar.\n")); return FALSE; } m_pToolBarWeb = pCommandBars->Add(_T("Web"), xtpBarTop); if (NULL == m_pToolBarWeb || !m_pToolBarWeb->LoadToolBar(IDR_TOOLBAR_WEB)) { TRACE(_T("ERROR: Unable to add Web toolbar.\n")); return FALSE; } m_pToolBarState = pCommandBars->Add(_T("State"), xtpBarTop); if (NULL == m_pToolBarState || !m_pToolBarState->LoadToolBar(IDR_TOOLBAR_STATE, FALSE)) { TRACE(_T("ERROR: Unable to add State toolbar.\n")); return FALSE; } m_pFullScreen = (CXTPToolBar*)pCommandBars->Add(_T("Full Screen"), xtpBarTop); if (!m_pFullScreen || !m_pFullScreen->LoadToolBar(IDR_TOOLBAR_FULLSCREEN)) { TRACE(_T("ERROR: Unable to add Full Screen toolbar.\n")); return -1; } m_pFullScreen->SetVisible(FALSE); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); // pCommandBars->GetCommandBarsOptions()->bShowPopupButtonsSelectedToolbarOnly = theApp.m_theme // > themeVS2010 ? TRUE : FALSE; pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); if (!UpdateMenuBar(m_nAppliedTheme)) { TRACE(_T("ERROR: Unable to update MenuBar.\n")); return FALSE; } return TRUE; } 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: { m_pMenuTitleBar = pCommandBars->SetMenuTitleBar(_T("Menu Title Bar"), IDR_MAINFRAME); 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); m_pMenuBar->SetShowGripper(FALSE); m_pMenuBar->RefreshMenu(); } else { TRACE(_T("ERROR: Unable to create Menu Bar.\n")); return FALSE; } break; } } m_pToolBarStandart->SetPosition(xtpBarFloating); m_pToolBarState->SetPosition(xtpBarFloating); m_pToolBarWeb->SetPosition(xtpBarFloating); m_pFullScreen->SetPosition(xtpBarFloating); m_pToolBarStandart->SetPosition(xtpBarTop); m_pToolBarState->SetPosition(xtpBarTop); m_pToolBarWeb->SetPosition(xtpBarTop); m_pFullScreen->SetPosition(xtpBarTop); DockRightOf(m_pToolBarState, m_pToolBarStandart); DockRightOf(m_pFullScreen, m_pToolBarState); return TRUE; } BOOL CMainFrame::CreateTabClient() { if (!GetTabClientWnd()->Attach(this, TRUE)) { TRACE(_T("ERROR: Unable to create tab client.\n")); return FALSE; } GetTabClientWnd()->ShowWorkspace(TRUE); GetTabClientWnd()->EnableToolTips(); GetTabClientWnd()->GetPaintManager()->m_bShowIcons = TRUE; GetTabClientWnd()->SetNewTabPosition(xtpWorkspaceNewTabLeftMost); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); GetTabClientWnd()->SetDockingPaneManager(GetDockingPaneManager()); return TRUE; } BOOL CMainFrame::UpdateTabClient(XTPPaintTheme nTheme) { UNREFERENCED_PARAMETER(nTheme); if (GetTabClientWnd()->IsAttached()) GetTabClientWnd()->Detach(); if (!GetTabClientWnd()->Attach(this, TRUE)) { TRACE(_T("ERROR: Unable to create tab client.\n")); return FALSE; } GetTabClientWnd()->ShowWorkspace(TRUE); GetTabClientWnd()->EnableToolTips(); GetTabClientWnd()->GetPaintManager()->m_bShowIcons = TRUE; GetTabClientWnd()->SetNewTabPosition(xtpWorkspaceNewTabLeftMost); GetTabClientWnd()->SetDockingPaneManager(GetDockingPaneManager()); return TRUE; } BOOL CMainFrame::CreateDockingPanes() { if (!GetDockingPaneManager()->InstallDockingPanes(this)) { TRACE(_T("ERROR: Unable to initialize docking panes.\n")); return FALSE; } // Create the Output pane if (!m_wndOutput.Create(_T("EDIT"), NULL, WS_HSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | WS_VISIBLE, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Output pane window.\n")); return FALSE; } CXTPDockingPane* pOutputPane = GetDockingPaneManager()->CreatePane( ID_VIEW_OUTPUT, XTP_DPI(CRect(0, 0, 150, 120)), xtpPaneDockBottom); if (NULL == pOutputPane) { TRACE(_T("ERROR: Unable to create Output pane.\n")); return FALSE; } // Create the Class View pane if (!m_wndClassView.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Class View pane window.\n")); return FALSE; } CXTPDockingPane* pClassesPane = GetDockingPaneManager()->CreatePane( ID_VIEW_CLASSES, XTP_DPI(CRect(0, 0, 230, 140)), xtpPaneDockLeft); if (NULL == pClassesPane) { TRACE(_T("ERROR: Unable to create Class View pane.\n")); return FALSE; } // Create the Resources pane if (!m_wndResourceView.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Resources pane window.\n")); return FALSE; } CXTPDockingPane* pResourcesPane = GetDockingPaneManager()->CreatePane( ID_VIEW_RESOURCES, XTP_DPI(CRect(0, 0, 230, 140)), xtpPaneDockLeft); if (NULL == pResourcesPane) { TRACE(_T("ERROR: Unable to create Resources pane.\n")); return FALSE; } // Create the Solution Explorer pane if (!m_wndSolutionExplorer.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Solution Exploded pane window.\n")); return FALSE; } CXTPDockingPane* pSolutionExplorerPane = GetDockingPaneManager()->CreatePane( ID_VIEW_SOLUTIONEXPLORER, XTP_DPI(CRect(0, 0, 230, 140)), xtpPaneDockLeft); if (NULL == pSolutionExplorerPane) { TRACE(_T("ERROR: Unable to create Solution Explorer pane.\n")); return FALSE; } GetDockingPaneManager()->AttachPane(pClassesPane, pSolutionExplorerPane); GetDockingPaneManager()->AttachPane(pResourcesPane, pClassesPane); // Create the Properties pane if (!m_wndProperties.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Properties pane window.\n")); return FALSE; } CXTPDockingPane* pPropertiesPane = GetDockingPaneManager()->CreatePane( ID_VIEW_PROPERTIES, XTP_DPI(CRect(0, 0, 180, 140)), xtpPaneDockBottom, pClassesPane); if (NULL == pPropertiesPane) { TRACE(_T("ERROR: Unable to create Properties pane.\n")); return FALSE; } // Create the Toolbox pane if (!m_wndToolbox.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { TRACE(_T("ERROR: Unable to create Toolbox pane window.\n")); return FALSE; } CXTPDockingPane* pToolboxPane = GetDockingPaneManager()->CreatePane( ID_VIEW_TOOLBOX, XTP_DPI(CRect(0, 0, 230, 140)), xtpPaneDockRight); if (NULL == pToolboxPane) { TRACE(_T("ERROR: Unable to create Toolbox pane.\n")); return FALSE; } pSolutionExplorerPane->Select(); CXTPImageManager* pImageManager = GetCommandBars()->GetImageManager(); ASSERT_VALID(pImageManager); pImageManager->InternalAddRef(); GetDockingPaneManager()->SetImageManager(pImageManager); GetDockingPaneManager()->EnableKeyboardNavigate(); GetDockingPaneManager()->SetAlphaDockingContext(TRUE); GetDockingPaneManager()->SetShowDockingContextStickers(TRUE); GetDockingPaneManager()->SetShowContentsWhileDragging(TRUE); GetDockingPaneManager()->SetDefaultPaneOptions(xtpPaneHasMenuButton); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2010); GetDockingPaneManager()->EnableFloatingFrameTheme(TRUE); GetDockingPaneManager()->SetClientMargin(0); GetDockingPaneManager()->SetTabClient(GetTabClientWnd()); return TRUE; } BOOL CMainFrame::CreateMessageBar() { _ASSERTE(!::IsWindow(m_wndMessageBar)); if (!m_wndMessageBar.Create(GetCommandBars())) { TRACE(_T("ERROR: Unable to create Message Bar.\n")); return FALSE; } m_wndMessageBar.AddButton(SC_CLOSE, NULL, _T("Close Message Bar")); m_wndMessageBar.AddButton(XTP_ID_CUSTOMIZE, _T("Options..."), _T("Show more options")); m_wndMessageBar.EnableMarkup(); m_wndMessageBar.SetMessage( _T("") _T(" ") _T(" SECURITY ") _T("WARNING") _T(" Certain content ") _T("has been disabled.") _T("")); return TRUE; } void CMainFrame::InitTooltips() { CXTPToolTipContext* pToolTipContext = GetCommandBars()->GetToolTipContext(); ASSERT_VALID(pToolTipContext); pToolTipContext->ShowTitleAndDescription(); pToolTipContext->ShowImage(TRUE, 0); pToolTipContext->SetMargin(XTP_DPI(CRect(2, 2, 2, 2))); pToolTipContext->SetMaxTipWidth(XTP_DPI_X(180)); pToolTipContext->SetFont(GetCommandBars()->GetPaintManager()->GetIconFont()); pToolTipContext->SetDelayTime(TTDT_INITIAL, 900); } void CMainFrame::OnCustomize() { XTPControlTheme nControlTheme = xtpControlThemeDefault; switch (theApp.GetAppTheme()) { case xtpThemeVisualStudio6: nControlTheme = xtpControlThemeDefault; break; case xtpThemeVisualStudio2005: nControlTheme = xtpControlThemeVisualStudio2005; break; case xtpThemeVisualStudio2008: nControlTheme = xtpControlThemeVisualStudio2008; break; case xtpThemeVisualStudio2010: nControlTheme = xtpControlThemeVisualStudio2010; break; case xtpThemeVisualStudio2012Dark: nControlTheme = xtpControlThemeVisualStudio2012Dark; break; case xtpThemeVisualStudio2012Light: nControlTheme = xtpControlThemeVisualStudio2012Light; break; case xtpThemeVisualStudio2015: nControlTheme = xtpControlThemeVisualStudio2015; break; case xtpThemeVisualStudio2017: nControlTheme = xtpControlThemeVisualStudio2017; break; case xtpThemeVisualStudio2019: nControlTheme = xtpControlThemeVisualStudio2019; break; case xtpThemeVisualStudio2022: nControlTheme = xtpControlThemeVisualStudio2022; break; default: nControlTheme = xtpControlThemeDefault; break; } CXTPCustomizeSheet cs(GetCommandBars()); cs.SetTheme(nControlTheme); CXTPCustomizeKeyboardPage pageKeyboard(&cs); cs.AddPage(&pageKeyboard); pageKeyboard.AddCategories(IDR_MAINFRAME, TRUE); CXTPCustomizeOptionsPage pageOptions(&cs); cs.AddPage(&pageOptions); CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage(); pCommands->AddCategories(IDR_MAINFRAME, TRUE); pCommands->InsertAllCommandsCategory(); pCommands->InsertBuiltInMenus(IDR_MAINFRAME); pCommands->InsertNewMenuCategory(); cs.DoModal(); } void CMainFrame::OnViewMessageBar() { m_wndMessageBar.ShowWindow(m_wndMessageBar.IsVisible() ? SW_HIDE : SW_SHOW); RecalcLayout(FALSE); } void CMainFrame::OnUpdateViewMessageBar(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->SetCheck(m_wndMessageBar.IsVisible()); } 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::OnWindowAutohideall() { CXTPDockingPaneInfoList& lstPanes = GetDockingPaneManager()->GetPaneList(); POSITION pos = lstPanes.GetHeadPosition(); while (pos) { CXTPDockingPane* pPane = lstPanes.GetNext(pos); if (!pPane->IsClosed() && !pPane->IsHidden()) GetDockingPaneManager()->HidePane(pPane); } } void CMainFrame::OnWindowCloseAll() { theApp.CloseAllDocuments(FALSE); } void CMainFrame::OnWindowMore() { CXTPWindowList dlg(this); dlg.DoModal(); } void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { CXTPMDIFrameWndEx::OnSettingChange(uFlags, lpszSection); } LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam) { BOOL bHandled = FALSE; if (XTP_DPN_SHOWWINDOW == wParam) { CXTPDockingPane* pPane = reinterpret_cast(lParam); ASSERT_VALID(pPane); if (!pPane->IsValid()) { switch (pPane->GetID()) { case ID_VIEW_CLASSES: pPane->Attach(&m_wndClassView); m_wndClassView.SetOwnerPane(pPane); break; case ID_VIEW_TOOLBOX: pPane->Attach(&m_wndToolbox); m_wndToolbox.SetOwnerPane(pPane); break; case ID_VIEW_RESOURCES: pPane->Attach(&m_wndResourceView); m_wndResourceView.SetOwnerPane(pPane); break; case ID_VIEW_SOLUTIONEXPLORER: pPane->Attach(&m_wndSolutionExplorer); m_wndSolutionExplorer.SetOwnerPane(pPane); break; case ID_VIEW_PROPERTIES: pPane->Attach(&m_wndProperties); m_wndProperties.SetOwnerPane(pPane); break; case ID_VIEW_OUTPUT: pPane->Attach(&m_wndOutput); m_wndOutput.SetOwnerPane(pPane); break; } } bHandled = TRUE; } else if (XTP_DPN_CONTEXTMENU == wParam) { XTP_DOCKINGPANE_CLICK* pClick = reinterpret_cast(lParam); _ASSERTE(NULL != pClick); CXTPDockingPane* pPopupPane = pClick->pPane; if (NULL != pPopupPane) { ShowDockingPanePopupMenu(pPopupPane, pClick->pt, pClick->rcExclude); bHandled = TRUE; } } return bHandled; } void CMainFrame::ShowDockingPanePopupMenu(CXTPDockingPane* pPopupPane, CPoint pt, LPRECT lprcExclude) { ASSERT_VALID(pPopupPane); CMenu menu; VERIFY(menu.LoadMenu(IDR_POPUP_PANES)); CMenu* pPopup = menu.GetSubMenu(0); if (pPopupPane->IsHidden()) { pPopup->CheckMenuItem(ID_POPUP_AUTOHIDE, MF_BYCOMMAND | MF_CHECKED); pPopup->EnableMenuItem(ID_POPUP_FLOATING, MF_BYCOMMAND | MF_DISABLED); pPopup->EnableMenuItem(ID_POPUP_DOCKABLE, MF_BYCOMMAND | MF_DISABLED); } else if (pPopupPane->GetOptions() & xtpPaneNoDockable) { pPopup->CheckMenuItem(ID_POPUP_FLOATING, MF_BYCOMMAND | MF_CHECKED); } else { pPopup->CheckMenuItem(ID_POPUP_DOCKABLE, MF_BYCOMMAND | MF_CHECKED); } TPMPARAMS tpm; tpm.cbSize = sizeof(TPMPARAMS); tpm.rcExclude = lprcExclude ? *lprcExclude : CRect(0, 0, 0, 0); int nCommand = GetCommandBars()->TrackPopupMenuEx( pPopup, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, NULL, &tpm); switch (nCommand) { case ID_POPUP_HIDE: pPopupPane->Close(); break; case ID_POPUP_AUTOHIDE: GetDockingPaneManager()->ToggleAutoHide(pPopupPane); break; case ID_POPUP_DOCKABLE: if (pPopupPane->GetOptions() & xtpPaneNoDockable) { pPopupPane->SetOptions(pPopupPane->GetOptions() & ~xtpPaneNoDockable); } break; case ID_POPUP_FLOATING: if ((pPopupPane->GetOptions() & xtpPaneNoDockable) == 0) { if (!pPopupPane->IsFloating()) { GetDockingPaneManager()->ToggleDocking(pPopupPane); } pPopupPane->SetOptions(pPopupPane->GetOptions() | xtpPaneNoDockable); } break; } } void CMainFrame::LoadRasterIcons() { CString strThemeSettings = theApp.GetAppThemeSettings(); UINT nMenuIcons = IDR_MAINFRAME; UINT nToolbar = IDR_TOOLBAR_EXT; UINT nState = IDR_TOOLBAR_STATE; UINT nWeb = IDR_TOOLBAR_WEB; int nFullscreen = IDR_TOOLBAR_FULLSCREEN; if (0 < strThemeSettings.Find(_T("BLUE"))) { nMenuIcons = IDR_MAINFRAME_LIGHT; nToolbar = IDR_TOOLBAR_EXT_LIGHT; nState = IDR_TOOLBAR_STATE_LIGHT; nWeb = IDR_TOOLBAR_WEB_LIGHT; nFullscreen = IDR_TOOLBAR_FULLSCREEN_LIGHT; } else if (0 < strThemeSettings.Find(_T("BLUEEXTRA"))) { nMenuIcons = IDR_MAINFRAME_LIGHT; nToolbar = IDR_TOOLBAR_EXT_LIGHT; nState = IDR_TOOLBAR_STATE_LIGHT; nWeb = IDR_TOOLBAR_WEB_LIGHT; nFullscreen = IDR_TOOLBAR_FULLSCREEN_LIGHT; } else if (0 < strThemeSettings.Find(_T("DARK"))) { nMenuIcons = IDR_MAINFRAME_DARK; nToolbar = IDR_TOOLBAR_EXT_DARK; nState = IDR_TOOLBAR_STATE_DARK; nWeb = IDR_TOOLBAR_WEB_DARK; nFullscreen = IDR_TOOLBAR_FULLSCREEN_DARK; } else if (0 < strThemeSettings.Find(_T("LIGHT"))) { nMenuIcons = IDR_MAINFRAME_LIGHT; nToolbar = IDR_TOOLBAR_EXT_LIGHT; nState = IDR_TOOLBAR_STATE_LIGHT; nWeb = IDR_TOOLBAR_WEB_LIGHT; nFullscreen = IDR_TOOLBAR_FULLSCREEN_LIGHT; } UINT menu[] = { ID_FILE_NEW_PROJECT, ID_PROJECT_ADDNEWITEM, ID_FILE_OPEN, ID_FILE_SAVE, ID_FILE_SAVE_ALL, ID_EDIT_CUT, ID_EDIT_COPY, ID_EDIT_PASTE, ID_EDIT_UNDO, ID_EDIT_REDO, ID_DEBUG_START, ID_EDIT_CONFIGURATION, ID_EDIT_PLATFORM, ID_FINDANDREPLACE_FINDINFILES, ID_EDIT_FIND_EX, ID_VIEW_SOLUTIONEXPLORER, ID_VIEW_PROPERTIES, ID_VIEW_RESOURCES, ID_VIEW_TOOLBOX, ID_VIEW_CLASSES }; XTPImageManager()->SetIcons(nMenuIcons, menu, _countof(menu), CSize(16, 16)); UINT toolbar[] = { ID_FILE_NEW, ID_FILE_PRINT, ID_PROJECT_ADDEXISTINGITEM, ID_FILE_NEW_BLANK, ID_FILE_OPENSOLUTION, ID_FILE_CLOSESOLUTION, ID_PROJECT_ADDCLASS, ID_BUILD_BUILDSOLUTION, ID_BUILD_COMPILE, ID_DEBUG_STARTWITHOUTDEBUG, ID_WINDOW_NEW, 0, ID_VIEW_OUTPUT, ID_VIEW_CLASSES }; XTPImageManager()->SetIcons(nToolbar, toolbar, _countof(toolbar), CSize(16, 16)); UINT state[] = { ID_STATE_COLOR_DEFAULT, ID_STATE_COLOR_ORANGE, ID_STATE_COLOR_BLUE }; XTPImageManager()->SetIcons(nState, state, _countof(state), CSize(16, 16)); UINT web[] = { ID_WEBBROWSER_BACK, ID_WEBBROWSER_FORWARD, ID_WEBBROWSER_STOP, ID_WEBBROWSER_REFRESH, ID_WEBBROWSER_HOME, ID_WEBBROWSER_SEARCH, ID_WEBBROWSER_FAVORITES, ID_WEBBROWSER_ORGANIZE, ID_WEBBROWSER_SYNC, ID_WEBBROWSER_PREV, ID_WEBBROWSER_NEXT, ID_WEBBROWSER_FONT, ID_WEBBROWSER_GOTO_URL }; XTPImageManager()->SetIcons(nWeb, web, _countof(web), CSize(16, 16)); UINT fs[] = { ID_VIEW_FULLSCREEN }; XTPImageManager()->SetIcons(nFullscreen, fs, _countof(fs), CSize(16, 16)); } void CMainFrame::LoadVectorIcons() { // } void CMainFrame::InitThemeDlg() { m_dlgTheme.ExcludeTheme( XTP_EXCLUDE_THEME_CUSTOM | XTP_EXCLUDE_THEME_OFFICE2000 | XTP_EXCLUDE_THEME_OFFICEXP | XTP_EXCLUDE_THEME_OFFICE2003 | XTP_EXCLUDE_THEME_OFFICE2007 | XTP_EXCLUDE_THEME_OFFICE2010 | XTP_EXCLUDE_THEME_OFFICE2013 | XTP_EXCLUDE_THEME_OFFICE2016 | XTP_EXCLUDE_THEME_NATIVEWINDOWS | XTP_EXCLUDE_THEME_NATIVEWINDOWS10 | XTP_EXCLUDE_THEME_NATIVEWINDOWS11 | XTP_EXCLUDE_THEME_VISUALSTUDIO2012); VERIFY(m_dlgTheme.Create(IDD_THEME_DIALOG, this)); m_dlgTheme.SetTheme(xtpThemeDlgVisualStudio2022, xtpThemeColor2019Blue, xtpThemeAccentUndef, xtpThemeRibbonBackUndef, TRUE); m_dlgTheme.EnableAutoPreview(TRUE); } 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 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; } UpdateTheme(); LoadRasterIcons(); LoadVectorIcons(); return 0; } 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(); GetTabClientWnd()->GetPaintManager()->RefreshMetrics(); SendMessage(WM_NCPAINT); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE); } 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)) { DisableStyle(); if (!UpdateMenuBar(nTheme)) { _ASSERTE(!"ERROR: Unable to update MenuBar.\n"); } if (!UpdateTabClient(nTheme)) { _ASSERTE(!"ERROR: Unable to update tab client.\n"); } } } _ASSERTE(NULL != lpzThemeSettings); switch (nTheme) { case xtpThemeNone: EnableNoStyle(bEnable); break; case xtpThemeVisualStudio6: EnableStyleVisualStudio98(bEnable); break; case xtpThemeVisualStudio2005: EnableStyleVisualStudio2005(bEnable); break; case xtpThemeVisualStudio2008: EnableStyleVisualStudio2008(bEnable); break; case xtpThemeVisualStudio2010: EnableStyleVisualStudio2010(bEnable); break; case xtpThemeVisualStudio2012Light: EnableStyleVisualStudio2012(TRUE, bEnable); break; case xtpThemeVisualStudio2012Dark: EnableStyleVisualStudio2012(FALSE, bEnable); break; case xtpThemeVisualStudio2015: EnableStyleVisualStudio2015(bEnable); break; case xtpThemeVisualStudio2017: EnableStyleVisualStudio2017(bEnable); break; case xtpThemeVisualStudio2019: EnableStyleVisualStudio2019(bEnable); break; case xtpThemeVisualStudio2022: EnableStyleVisualStudio2022(bEnable); break; default: _ASSERTE(!"Unsupported theme"); break; } } void CMainFrame::DisableStyle() { SetFrameIcon(CSize(16, 16)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(FALSE); GetCommandBars()->SetAllCaps(FALSE); m_wndMessageBar.SetHeight(XTP_DPI_Y(35)); m_wndStatusBar.SetAllCaps(FALSE); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); DisableFrameTheme(); GetDockingPaneManager()->SetTheme(xtpPaneThemeDefault); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2010); GetDockingPaneManager()->SetClientMargin(0); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(FALSE); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeDefault); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); } void CMainFrame::EnableNoStyle(BOOL bEnable /*= TRUE*/) { if (bEnable) { CXTPCommandBarsFrameHook::m_bAllowDwm = FALSE; EnableFrameTheme(GetCommandBars()); } else { DisableFrameTheme(); } UpdateChildrenTheme(); } void CMainFrame::EnableStyleVisualStudio98(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(FALSE); m_pMenuBar->SetShowGripper(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(0); DisableFrameTheme(); GetDockingPaneManager()->SetTheme(xtpPaneThemeGrippered); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2005); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(FALSE); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio6); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2005(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(FALSE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(0); DisableFrameTheme(); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2005); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2005); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(FALSE); // GetDockingPaneManager()->GetPaintManager()->GetPanelPaintManager()->m_bShowIcons = TRUE; // GetDockingPaneManager()->GetPaintManager()->GetTabPaintManager()->m_bShowIcons = // FALSE; theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2005); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2005); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2008(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(FALSE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); DisableFrameTheme(); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2008); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2008); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(FALSE); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2008); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2008); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(FALSE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); DisableFrameTheme(); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2010); GetDockingPaneManager()->SetDockingContextStickerStyle(xtpPaneStickerStyleVisualStudio2010); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2010); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2010); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2012(BOOL bLight, BOOL bEnable /*= TRUE*/) { if (bEnable) { SetFrameIcon(CSize(20, 20)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(TRUE); GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); EnableFrameTheme(GetCommandBars()); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2012); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); CString strThemeSettings = theApp.GetAppThemeSettings(); if (0 < strThemeSettings.Find(_T("DARK"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2012Dark); else if (0 < strThemeSettings.Find(_T("LIGHT"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2012Light); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2012); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, bLight ? xtpControlThemeVisualStudio2012Light : xtpControlThemeVisualStudio2012Dark); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2015(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetFrameIcon(CSize(20, 20)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(TRUE); GetCommandBars()->SetAllCaps(TRUE); m_wndStatusBar.SetAllCaps(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); EnableFrameTheme(GetCommandBars()); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2015); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); CString strThemeSettings = theApp.GetAppThemeSettings(); if (0 < strThemeSettings.Find(_T("BLUE"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2015Blue); else if (0 < strThemeSettings.Find(_T("DARK"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2015Dark); else if (0 < strThemeSettings.Find(_T("LIGHT"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2015Light); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2015); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2015); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2017(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetFrameIcon(CSize(20, 20)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); EnableFrameTheme(GetCommandBars()); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2017); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); CString strThemeSettings = theApp.GetAppThemeSettings(); if (0 < strThemeSettings.Find(_T("BLUE"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2017Blue); else if (0 < strThemeSettings.Find(_T("BLUEEXTRA"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2017BlueExtra); else if (0 < strThemeSettings.Find(_T("DARK"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2017Dark); else if (0 < strThemeSettings.Find(_T("LIGHT"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2017Light); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2017); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2017); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2019(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetFrameIcon(CSize(20, 20)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); EnableFrameTheme(GetCommandBars()); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2019); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); CString strThemeSettings = theApp.GetAppThemeSettings(); if (0 < strThemeSettings.Find(_T("BLUE"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2019Blue); else if (0 < strThemeSettings.Find(_T("BLUEEXTRA"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2019BlueExtra); else if (0 < strThemeSettings.Find(_T("DARK"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2019Dark); else if (0 < strThemeSettings.Find(_T("LIGHT"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2019Light); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2019); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2019); } else { DisableStyle(); } } void CMainFrame::EnableStyleVisualStudio2022(BOOL bEnable /*= TRUE*/) { if (bEnable) { SetFrameIcon(CSize(20, 20)); SetTooltipStyle(xtpToolTipStandard); m_pToolBarState->SetVisible(TRUE); m_wndMessageBar.SetHeight(XTP_DPI_Y(30)); GetTabClientWnd()->SetFlags(xtpWorkspaceHideClose | xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles | xtpWorkspaceShowCloseTab); EnableFrameTheme(GetCommandBars()); GetDockingPaneManager()->SetTheme(xtpPaneThemeVisualStudio2022); GetDockingPaneManager()->SetClientMargin(XTP_DPI_X(5)); GetDockingPaneManager()->ShowFloatingCaptionMaximizeButton(TRUE); CString strThemeSettings = theApp.GetAppThemeSettings(); if (0 < strThemeSettings.Find(_T("BLUE"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2022Blue); else if (0 < strThemeSettings.Find(_T("BLUEEXTRA"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2022BlueExtra); else if (0 < strThemeSettings.Find(_T("DARK"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2022Dark); else if (0 < strThemeSettings.Find(_T("LIGHT"))) GetDockingPaneManager()->SetDockingContextStickerStyle( xtpPaneStickerStyleVisualStudio2022Light); theApp.GetPaneColorSet()->RefreshMetrics(xtpPaneThemeVisualStudio2022); UpdateChildrenTheme(); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2022); } else { DisableStyle(); } } void CMainFrame::SetTooltipStyle(XTPToolTipStyle nStyle) { CXTPToolTipContext* pToolTipContext = NULL; 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() { int nTabItemCount = GetTabClientWnd()->GetItemCount(); for (int nTab = 0; nTab < nTabItemCount; ++nTab) { CXTPTabManagerItem* pTabItem = GetTabClientWnd()->GetItem(nTab); if (NULL != pTabItem) { HWND hWnd = pTabItem->GetHandle(); if (NULL != hWnd) { CChildFrame* pChildFrame = DYNAMIC_DOWNCAST(CChildFrame, CWnd::FromHandle(hWnd)); if (NULL != pChildFrame) { pChildFrame->OnUpdateMDIChildrenTheme(); } } } } } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CXTPMDIFrameWndEx::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CXTPMDIFrameWndEx::Dump(dc); } #endif //_DEBUG void CMainFrame::OnStateColor(UINT nID) { if (m_nStateColor == nID) return; switch (nID) { case ID_STATE_COLOR_DEFAULT: XTPGetApplication()->SetAmbientProperty(xtpApplicationStateColor, LONG(COLORREF_NULL)); break; case ID_STATE_COLOR_ORANGE: XTPGetApplication()->SetAmbientProperty(xtpApplicationStateColor, LONG(RGB(202, 81, 0))); break; case ID_STATE_COLOR_BLUE: XTPGetApplication()->SetAmbientProperty(xtpApplicationStateColor, LONG(RGB(0, 122, 204))); break; } m_nStateColor = nID; } void CMainFrame::OnUpdateStateColor(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->SetCheck(pCmdUI->m_nID == m_nStateColor); XTPPaintTheme nTheme = theApp.GetAppTheme(); BOOL bVS2015Plus = ((nTheme == xtpThemeVisualStudio2015) || (nTheme == xtpThemeVisualStudio2017) || (nTheme == xtpThemeVisualStudio2019) || (nTheme == xtpThemeVisualStudio2022)); pCmdUI->Enable(bVS2015Plus); } LRESULT CMainFrame::OnTabToDockpane(WPARAM wParam, LPARAM /*lParam*/) { UNREFERENCED_PARAMETER(wParam); // CXTPTabManagerItem* pItem = (CXTPTabManagerItem*)wParam; return 1; } void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { static HWND hFocus = NULL; if (nState == WA_INACTIVE) { hFocus = GetDockingPaneManager()->GetActivePane() != NULL ? ::GetFocus() : NULL; } CXTPMDIFrameWndEx::OnActivate(nState, pWndOther, bMinimized); if (nState != WA_INACTIVE && hFocus) { ::SetFocus(hFocus); hFocus = NULL; } } void CMainFrame::OnEditConfiguration(NMHDR* pNMHDR, LRESULT* pResult) { NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR; CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl; if (pControl->GetType() == xtpControlComboBox) { int nState = pControl->GetCurSel(); if (nState != 2) { m_nConfiguration = nState; } else { MessageBox(_T("Configuration Manager...")); pControl->SetCurSel(m_nConfiguration); } *pResult = TRUE; // Handled } } void CMainFrame::OnUpdateEditConfiguration(CCmdUI* pCmdUI) { CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther; if (pToolBar && !XTPMouseManager()->IsTrackedLock()) { CXTPControlComboBox* pStateCombo = (CXTPControlComboBox*)pToolBar->GetControls()->GetAt( pCmdUI->m_nIndex); if (pStateCombo->GetType() == xtpControlComboBox) { pStateCombo->SetCurSel(m_nConfiguration); } } pCmdUI->Enable(TRUE); } void CMainFrame::OnEditPlatform(NMHDR* pNMHDR, LRESULT* pResult) { NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR; CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl; if (pControl->GetType() == xtpControlComboBox) { int nState = pControl->GetCurSel(); if (nState != 2) { m_nPlatform = nState; } else { MessageBox(_T("Configuration Manager...")); pControl->SetCurSel(m_nPlatform); } *pResult = TRUE; // Handled } } void CMainFrame::OnUpdateEditPlatform(CCmdUI* pCmdUI) { CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther; if (pToolBar && !XTPMouseManager()->IsTrackedLock()) { CXTPControlComboBox* pStateCombo = (CXTPControlComboBox*)pToolBar->GetControls()->GetAt( pCmdUI->m_nIndex); if (pStateCombo->GetType() == xtpControlComboBox) { pStateCombo->SetCurSel(m_nPlatform); } } pCmdUI->Enable(TRUE); } void CMainFrame::OnView(UINT nID) { GetDockingPaneManager()->ShowPane(nID); } void CMainFrame::OnUpdateView(CCmdUI* pCmdUI) { pCmdUI->Enable(TRUE); } void CMainFrame::InitLayout() { // CXTPPropExchangeIniFile px(TRUE, 0, _T("Settings")); // To serialize to ini file CXTPPropExchangeXMLNode px(TRUE, 0, _T("Settings")); // To serialize to XML file if (px.LoadFromFile(m_strIniFileName)) { CXTPPropExchangeSection pxTaskPanel(px.GetSection(_T("TaskPanel"))); m_wndToolbox.DoPropExchange(&pxTaskPanel); CXTPPropExchangeSection pxNormalLayout(px.GetSection(_T("NormalLayout"))); ExchangeLayout(&pxNormalLayout); m_pFullScreenLayout = DYNAMIC_DOWNCAST(CXTPPropExchangeXMLNode, px.GetSection(_T("FullScreenLayout"))); _ASSERTE(m_pFullScreenLayout); } else { m_wndToolbox.ResetToolboxItems(); } } void CMainFrame::OnFullScreen() { m_bFullScreen ^= 1; CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings")); CXTPPropExchangeXMLNode* pxLayoutSave = DYNAMIC_DOWNCAST(CXTPPropExchangeXMLNode, px.GetSection(_T("FullScreenLayout"))); _ASSERTE(pxLayoutSave); // Save current layout if (pxLayoutSave != 0) { ExchangeLayout(pxLayoutSave, FALSE); } // If Full screen layout exists if (m_pFullScreenLayout && m_pFullScreenLayout->IsSectionExists(_T("CommandBars"))) { // Set it m_pFullScreenLayout->SetLoading(TRUE); ExchangeLayout(m_pFullScreenLayout, FALSE); } // Else create new fullscreen layout. Hide all toolbars and DockingPanes. else { for (int i = 0; i < GetCommandBars()->GetCount(); i++) { CXTPToolBar* pToolBar = GetCommandBars()->GetAt(i); pToolBar->SetVisible((pToolBar->GetType() == xtpBarTypeMenuBar) || (pToolBar->GetBarID() == IDR_TOOLBAR_FULLSCREEN)); } GetDockingPaneManager()->CloseAll(); } // Save old layout if (m_pFullScreenLayout) { delete m_pFullScreenLayout; } m_pFullScreenLayout = pxLayoutSave; if (m_bFullScreen) { GetWindowRect(&m_rcMainFrame); ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0); // Now resize the main window CRect rcScreen = XTPMultiMonitor()->GetScreenArea(this); int cxBorder = ::GetSystemMetrics(SM_CXBORDER); int cyBorder = ::GetSystemMetrics(SM_CYBORDER); SetWindowPos(NULL, rcScreen.left - cxBorder, rcScreen.top - cyBorder, rcScreen.Width() + cxBorder * 2, rcScreen.Height() + cyBorder * 2, SWP_NOZORDER); // m_wndStatusBar.ShowWindow(SW_HIDE); } else { ModifyStyle(0, WS_CAPTION | WS_THICKFRAME); MoveWindow(&m_rcMainFrame); // m_wndStatusBar.ShowWindow(SW_SHOW); } RecalcLayout(TRUE); } void CMainFrame::ExchangeLayout(CXTPPropExchange* pPX, BOOL bSerializeControls /*= TRUE*/) { XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; param.bSerializeControls = bSerializeControls; CXTPPropExchangeSection pxCommandBars(pPX->GetSection(_T("CommandBars"))); GetCommandBars()->DoPropExchange(&pxCommandBars, ¶m); CXTPPropExchangeSection secShortcuts(pPX->GetSection(_T("Shortcuts"))); GetCommandBars()->GetShortcutManager()->DoPropExchange(&secShortcuts); CXTPPropExchangeSection secOptions(pPX->GetSection(_T("Options"))); GetCommandBars()->GetCommandBarsOptions()->DoPropExchange(&secOptions, TRUE); CXTPPropExchangeSection pxDockingPane(pPX->GetSection(_T("DockingPane"))); GetDockingPaneManager()->DoPropExchange(&pxDockingPane); } void CMainFrame::OnUpdateFullScreen(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_bFullScreen); }