// GUI_VisualStudio.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 "MainFrm.h" #include "ChildFrm.h" #include "GUI_VisualStudioDoc.h" #include "GUI_VisualStudioView.h" #include #pragma comment(lib, "Shlwapi") #ifdef _DEBUG # define new DEBUG_NEW #endif // CGUI_VisualStudioApp IMPLEMENT_DYNAMIC(CGUI_VisualStudioApp, CXTPWinApp); BEGIN_MESSAGE_MAP(CGUI_VisualStudioApp, CXTPWinApp) ON_COMMAND(ID_FILE_NEW, OnFileNew) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_FILE_PRINT_SETUP, OnFilePrintSetup) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) END_MESSAGE_MAP() // The one and only CGUI_VisualStudioApp object CGUI_VisualStudioApp theApp; // CGUI_VisualStudioApp construction CGUI_VisualStudioApp::CGUI_VisualStudioApp() { // TODO: replace application ID string below with unique ID string; recommended // format for string is CompanyName.ProductName.SubProduct.VersionInformation // SetAppID(_T("GUI_VisualStudio.AppID.NoVersion")); // TODO: add construction code here, // Place all significant initialization in InitInstance } CGUI_VisualStudioApp::~CGUI_VisualStudioApp() { } // CGUI_VisualStudioApp initialization BOOL CGUI_VisualStudioApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CXTPWinApp::InitInstance(); AfxEnableControlContainer(); CXTPWinDwmWrapper().SetProcessDPIAware(); #if _MSC_VER <= 1200 // MFC 6.0 or earlier # ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL # else Enable3dControlsStatic(); // Call this when linking to MFC statically # endif #endif CString ver; ver.Format(_T("Codejock %s v%d.%d.%d"), _XTP_PACKAGE_NAME, _XTPLIB_VERSION_MAJOR, _XTPLIB_VERSION_MINOR, _XTPLIB_VERSION_REVISION); SetRegistryKey(ver); LoadStdProfileSettings(); // Load standard INI file options (including MRU) InitVisualStyles(); SAFE_DELETE(m_pRecentFileList); m_pRecentFileList = new CXTPRecentFileList(0, _T("Recent File List"), _T("File%d"), 10); m_pRecentFileList->ReadList(); CMultiDocTemplate* pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME, RUNTIME_CLASS(CGUI_VisualStudioDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CGUI_VisualStudioView)); AddDocTemplate(pDocTemplate); CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; AfxMessageBox(IDS_MAINFRAME_LOADING_FAILED, MB_ICONERROR); return FALSE; } m_pMainWnd = pMainFrame; CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (!ProcessShellCommand(cmdInfo)) return FALSE; m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } int CGUI_VisualStudioApp::ExitInstance() { AfxOleTerm(FALSE); return CXTPWinApp::ExitInstance(); } void CGUI_VisualStudioApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } XTPPaintTheme CGUI_VisualStudioApp::GetAppTheme(XTPPaintTheme nDefaultTheme /*= xtpThemeNone*/) const { UINT nTheme = const_cast(this)->GetProfileInt(_T(""), _T("Theme"), nDefaultTheme); return static_cast(nTheme); } CString CGUI_VisualStudioApp::GetAppThemeSettings(LPCTSTR lpDefaultSettings /*= NULL*/) { CString strThemeSettings = const_cast(this)->GetProfileString( _T(""), _T("ThemeSettings"), lpDefaultSettings); strThemeSettings.MakeUpper(); return strThemeSettings; } void CGUI_VisualStudioApp::SetAppTheme(XTPPaintTheme nTheme, LPCTSTR lpThemeSettings /*= NULL*/, BOOL bUpdateResources /*= TRUE*/) { UNREFERENCED_PARAMETER(bUpdateResources); if (NULL != lpThemeSettings) { XTPThemeDLL()->SetHandle(lpThemeSettings); } else { XTPThemeDLL()->Reset(); } XTPPaintManager()->SetTheme(nTheme); WriteProfileInt(_T(""), _T("Theme"), nTheme); CString strThemeSettings; if (NULL != lpThemeSettings) { strThemeSettings = lpThemeSettings; strThemeSettings.MakeUpper(); } WriteProfileString(_T(""), _T("ThemeSettings"), strThemeSettings); } void CGUI_VisualStudioApp::InitVisualStyles() { XTPPaintTheme nTheme = GetAppTheme(xtpThemeVisualStudio2022); CString strThemeSettings = GetAppThemeSettings(xtpIniVisualStudio2022Blue); SetAppTheme(nTheme, strThemeSettings); } CPaneColorSet* CGUI_VisualStudioApp::GetPaneColorSet() { return &m_csPane; } BOOL CGUI_VisualStudioApp::GetStylesPath(CString& strPath, LPCTSTR lpFileName /*= NULL*/) { TCHAR szPath[MAX_PATH + 1] = { _T('\0') }; if (0 == ::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, MAX_PATH + 1)) { TRACE(_T("ERROR: Unable to obtain module file name.\n")); return FALSE; } ::PathRemoveFileSpec(szPath); SIZE_T cchAdditional = 1 + _tcslen(_T("Styles")) + (NULL != lpFileName ? 1 + _tcslen(lpFileName) : 0) + 1; if (_countof(szPath) < (_tcslen(szPath) + cchAdditional)) { TRACE(_T("ERROR: Style path is too long.\n")); return FALSE; } if (!::PathAppend(szPath, _T("Styles"))) { TRACE(_T("ERROR: Unable to append path.\n")); return FALSE; } if (NULL != lpFileName) { if (!::PathAppend(szPath, lpFileName)) { TRACE(_T("ERROR: Unable to append path.\n")); return FALSE; } } strPath = szPath; return TRUE; } // CGUI_VisualStudioApp message handlers // // Helpers // BOOL CreateImageList(CImageList& il, UINT nID) { if (!il.Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 1)) { TRACE(_T("ERROR: Unable to create image list.\n")); return FALSE; } CBitmap bmp; if (!bmp.LoadBitmap(nID)) { TRACE(_T("ERROR: Unable to load bitmap.\n")); return FALSE; } il.Add(&bmp, CXTPImageManager::GetBitmapMaskColor(bmp, CPoint(0, 0))); return TRUE; }