// ExcelTabDlg.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 "ExcelTab.h" #include "ExcelTabDlg.h" #include "ExcelTabProperties.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CExcelTabDlg dialog CExcelTabDlg::CExcelTabDlg(CWnd* pParent /*=NULL*/) : CXTPResizeDialog(CExcelTabDlg::IDD, pParent) , m_dwTabStyle(0) , m_bBottom(TRUE) , m_bHasArrows(TRUE) , m_bHasHomeEnd(FALSE) , m_bHScroll(TRUE) , m_bSquareTabs(TRUE) , m_pSheet7(NULL) , m_pSheet8(NULL) , m_pExcelTabCtrl(NULL) { m_bThemeApplied = FALSE; m_nAppliedTheme = xtpThemeNone; m_bEnableDefault = FALSE; m_bEnableFlat = FALSE; m_bEnableUltraFlat = FALSE; UpdateExcelTabCtrlStyle(); // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CExcelTabDlg::DoDataExchange(CDataExchange* pDX) { CXTPResizeDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CExcelTabDlg) DDX_Control(pDX, IDC_BORDER_TAB, m_staticBorder); DDX_Control(pDX, IDC_THEME, m_buttonTheme); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CExcelTabDlg, CXTPResizeDialog) //{{AFX_MSG_MAP(CExcelTabDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_DESTROY() ON_BN_CLICKED(IDC_PROPERTIES, OnProperties) ON_WM_XTP_THEMECHANGED() ON_BN_CLICKED(IDC_THEME, OnThemeDlg) ON_MESSAGE(WM_XTP_SETCONTROLTHEME, OnSetControlTheme) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CExcelTabDlg message handlers BOOL CExcelTabDlg::OnInitDialog() { CXTPResizeDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. _ASSERTE((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); _ASSERTE(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon InitThemeDlg(); // Set the default font for all dialog controls. SendMessageToDescendants(WM_SETFONT, (WPARAM)(HFONT)XTPFontManager()->GetFont()); // Set control resizing. SetResize(IDC_BORDER_TAB, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDC_PROPERTIES, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMLEFT); SetResize(IDOK, XTP_ANCHOR_BOTTOMRIGHT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDCANCEL, XTP_ANCHOR_BOTTOMRIGHT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDC_THEME, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMLEFT); CalcTabRect(); CreateExcelTabCtrl(); LoadPlacement(_T("CExcelTabDlg")); // CenterWindow(); return TRUE; // return TRUE unless you set the focus to a control } void CExcelTabDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CXTPResizeDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CExcelTabDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CXTPResizeDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CExcelTabDlg::OnQueryDragIcon() { return (HCURSOR)m_hIcon; } void CExcelTabDlg::OnDestroy() { CXTPResizeDialog::OnDestroy(); // Save window placement SavePlacement(_T("CExcelTabDlg")); if (::IsWindow(m_pSheet7->GetSafeHwnd())) m_pSheet7->DestroyWindow(); if (::IsWindow(m_pSheet8->GetSafeHwnd())) m_pSheet8->DestroyWindow(); SAFE_DELETE(m_pExcelTabCtrl); } void CExcelTabDlg::CalcTabRect() { CXTPWindowRect rcBorder(&m_staticBorder); ScreenToClient(&rcBorder); // get the size of the thumb box in a horizontal scroll bar. int cy = ::GetSystemMetrics(SM_CXHTHUMB); // SM_CYHSCROLL CRect rTabCtrl = rcBorder; rTabCtrl.DeflateRect(XTP_DPI_X(2), XTP_DPI_Y(2)); CRect rcCtrl = rcBorder; rcCtrl.DeflateRect(XTP_DPI_X(2), XTP_DPI_Y(1), XTP_DPI_X(2), cy + XTP_DPI_Y(1)); // Create the flat tab control. m_rcCtrl = rTabCtrl; } BOOL CExcelTabDlg::CreateExcelTabCtrl() { int iSel = 0; m_pExcelTabCtrl = new CXTPExcelTabCtrl(); if (!m_pExcelTabCtrl->Create(WS_CHILD | WS_VISIBLE | m_dwTabStyle, m_rcCtrl, this, IDC_EXCELTAB_CTRL)) { TRACE(_T("ERROR: Unable to create ExcelTabCtrl.\n")); return FALSE; } m_pExcelTabCtrl->ModifyStyleEx(NULL, WS_EX_STATICEDGE); if (!CreateSheet1()) return FALSE; if (!CreateSheet2()) return FALSE; if (!CreateSheet3()) return FALSE; if (!CreateSheet4()) return FALSE; if (!CreateSheet5()) return FALSE; if (!CreateSheet6()) return FALSE; if (!CreateSheet7()) return FALSE; if (!CreateSheet8()) return FALSE; // Insert tabs into the flat tab control. m_pExcelTabCtrl->InsertItem(0, _T("Build"), &m_sheet1); m_pExcelTabCtrl->InsertItem(1, _T("Debug"), &m_sheet2); m_pExcelTabCtrl->InsertItem(2, _T("Find in Files 1"), &m_sheet3); m_pExcelTabCtrl->InsertItem(3, _T("Find in Files 2"), &m_sheet4); m_pExcelTabCtrl->InsertItem(4, _T("Results"), &m_sheet5); m_pExcelTabCtrl->InsertItem(5, _T("SQL Debugging"), &m_sheet6); m_pExcelTabCtrl->InsertItem(6, _T("Form View"), m_pSheet7); m_pExcelTabCtrl->InsertItem(7, _T("Scroll View"), m_pSheet8); // set custom colors for the first tab. m_pExcelTabCtrl->SetTabBackColor(0, RGB(226, 239, 217)); m_pExcelTabCtrl->SetTabTextColor(0, RGB(83, 129, 53)); m_pExcelTabCtrl->SetSelTabBackColor(0, RGB(226, 239, 217)); m_pExcelTabCtrl->SetSelTabTextColor(0, RGB(55, 86, 35)); m_pExcelTabCtrl->SetCurSel(iSel); // enable resizing for the flat tab control. SetResize(IDC_EXCELTAB_CTRL, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMRIGHT); return TRUE; } BOOL CExcelTabDlg::CreateSheet1() { if (!m_sheet1.Create(WS_CHILD | LVS_REPORT | LVS_NOCOLUMNHEADER, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET1)) { TRACE(_T("ERROR: Unable to create sheet1.\n")); return FALSE; } m_sheet1.SetRowColors(theApp.m_clrText, theApp.m_clrBack); ListView_SetExtendedListViewStyleEx(m_sheet1.m_hWnd, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); m_sheet1.InsertColumn(0, _T("Column"), LVCFMT_LEFT, 512); m_sheet1.InsertItem(0, _T("--------------------Configuration: ExcelTabView - Win32 ") _T("Debug--------------------")); m_sheet1.InsertItem(1, _T("Compiling resources...")); m_sheet1.InsertItem(2, _T("Compiling...")); m_sheet1.InsertItem(3, _T("StdAfx.cpp")); m_sheet1.InsertItem(5, _T("Compiling...")); m_sheet1.InsertItem(6, _T("ExcelEditCtrl.cpp")); m_sheet1.InsertItem(7, _T("ExcelFormView.cpp")); m_sheet1.InsertItem(8, _T("ExcelListCtrl.cpp")); m_sheet1.InsertItem(9, _T("ExcelScrollView.cpp")); m_sheet1.InsertItem(10, _T("ExcelTab.cpp")); m_sheet1.InsertItem(11, _T("ExcelTabDoc.cpp")); m_sheet1.InsertItem(12, _T("ExcelTabProperties.cpp")); m_sheet1.InsertItem(13, _T("ExcelTabView.cpp")); m_sheet1.InsertItem(14, _T("ExcelTreeCtrl.cpp")); m_sheet1.InsertItem(15, _T("MainFrm.cpp")); m_sheet1.InsertItem(16, _T("Generating Code...")); m_sheet1.InsertItem(17, _T("Linking...")); m_sheet1.InsertItem(18, _T("")); m_sheet1.InsertItem(19, _T("ExcelTabView.exe - 0 error(s), 0 warning(s)")); return TRUE; } BOOL CExcelTabDlg::CreateSheet2() { if (!m_sheet2.Create(WS_CHILD | WS_TABSTOP | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET2)) { TRACE(_T("ERROR: Unable to create sheet2.\n")); return FALSE; } m_sheet2.Initialize(this); m_sheet2.SetWindowText( _T("Loaded 'C:\\WINNT\\System32\\ntdll.dll', no matching symbolic information found.\r\n") _T("Loaded symbols for 'C:\\WINNT\\system32\\MFC42D.DLL'\r\n") _T("Loaded symbols for 'C:\\WINNT\\system32\\MSVCRTD.DLL'\r\n") _T("Loaded 'C:\\WINNT\\system32\\KERNEL32.DLL', no matching symbolic information ") _T("found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\GDI32.DLL', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\USER32.DLL', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\ADVAPI32.DLL', no matching symbolic information ") _T("found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\rpcrt4.dll', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\SHELL32.DLL', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\shlwapi.dll', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\comctl32.dll', no matching symbolic information ") _T("found.\r\n") _T("Loaded symbols for 'C:\\WINNT\\system32\\MFCO42D.DLL'\r\n") _T("Loaded 'C:\\WINNT\\system32\\OLE32.DLL', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\OLEAUT32.DLL', no matching symbolic information ") _T("found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\lpk.dll', no matching symbolic information found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\usp10.dll', no matching symbolic information found.\r\n") _T("XTTOOLKIT_DLL.DLL Initializing!\r\n") _T("Loaded 'C:\\WINNT\\system32\\indicdll.dll', no matching symbolic information ") _T("found.\r\n") _T("Loaded 'C:\\WINNT\\system32\\imm32.dll', no matching symbolic information found.\r\n") _T("The program 'D:\\Controls\\Bin\\ExcelTabView.exe' has exited with code 0 (0x0).\r\n")); return TRUE; } BOOL CExcelTabDlg::CreateSheet3() { if (!m_sheet3.Create(WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | WS_VSCROLL, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET3)) { TRACE(_T("ERROR: Unable to create sheet3.\n")); return FALSE; } HTREEITEM file; file = m_sheet3.InsertItem(_T("D:\\Controls\\Samples\\ExcelTabView\\EditCtrlForFlatTab.cpp")); m_sheet3.InsertItem(_T("Line 92: pSB->Create(WS_CHILD, CRect(0, 0, 0, 0), (CWnd ") _T("*)this, 0)"), 0, 0, file); file = m_sheet3.InsertItem(_T("D:\\Controls\\Samples\\ExcelTabView\\ExcelTabView.rc")); m_sheet3.InsertItem(_T("Line 190:STYLE WS_CHILD"), 0, 0, file); file = m_sheet3.InsertItem(_T("D:\\Controls\\Samples\\ExcelTabView\\ExcelTabView.cpp")); m_sheet3.InsertItem(_T("Line 92: pSB->Create(WS_CHILD, CRect(0, 0, 0, 0), (CWnd ") _T("*)this, 0)"), 0, 0, file); m_sheet3.InsertItem(_T("Line 265: if ") _T("(!m_pExcelTabView->Create(WS_CHILD|WS_VISIBLE|m_dwTabStyle,"), 0, 0, file); m_sheet3.InsertItem(_T("Line 293: if (!m_sheet1.Create(WS_CHILD | "), 0, 0, file); m_sheet3.InsertItem(_T("Line 303: if (!m_sheet2.Create( WS_CHILD | WS_TABSTOP | ") _T("WS_CLIPCHILDREN |"), 0, 0, file); m_sheet3.InsertItem(_T("Line 312: DWORD dwStyle = WS_CHILD | LBS_NOINTEGRALHEIGHT | ") _T("WS_TABSTOP | WS_VSCROLL;"), 0, 0, file); m_sheet3.InsertItem(_T("Line 316: WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | ") _T("TVS_LINESATROOT | WS_VSCROLL, "), 0, 0, file); m_sheet3.InsertItem(_T("Line 348: !((CWnd *)m_pSheet7)->Create(NULL, NULL, WS_CHILD, "), 0, 0, file); file = m_sheet3.InsertItem(_T("D:\\Controls\\Samples\\ExcelTabView\\SampleFormView.cpp")); m_sheet3.InsertItem( _T("Line 79: m_ScrollBarH.Create(WS_CHILD, CRect(0, 0, 0, 0), this, 0);"), 0, 0, file); return TRUE; } BOOL CExcelTabDlg::CreateSheet4() { DWORD dwStyle = WS_CHILD | LBS_NOINTEGRALHEIGHT | WS_TABSTOP | WS_VSCROLL | LBS_SORT | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS; if (!m_sheet4.Create(dwStyle, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET4)) { TRACE(_T("ERROR: Unable to create sheet4.\n")); return FALSE; } m_sheet4.Initialize(); m_sheet4.AddString(_T("Find in Files 2 Tab Output...")); return TRUE; } BOOL CExcelTabDlg::CreateSheet5() { DWORD dwStyle = WS_CHILD | LBS_NOINTEGRALHEIGHT | WS_TABSTOP | WS_VSCROLL | LBS_SORT | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS; if (!m_sheet5.Create(dwStyle, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET5)) { TRACE(_T("ERROR: Unable to create sheet5.\n")); return FALSE; } m_sheet5.Initialize(); m_sheet5.AddString(_T("Results Tab Output...")); return TRUE; } BOOL CExcelTabDlg::CreateSheet6() { DWORD dwStyle = WS_CHILD | LBS_NOINTEGRALHEIGHT | WS_TABSTOP | WS_VSCROLL | LBS_SORT | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS; if (!m_sheet6.Create(dwStyle, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET6)) { TRACE(_T("ERROR: Unable to create sheet6.\n")); return FALSE; } m_sheet6.Initialize(); m_sheet6.AddString(_T("SQL Debugging Tab Output...")); return TRUE; } BOOL CExcelTabDlg::CreateSheet7() { // views must be created dynamically because they are destroyed during // window destruction CCreateContext cc; ::ZeroMemory(&cc, sizeof(cc)); cc.m_pCurrentDoc = NULL; m_pSheet7 = (CSheetFormView*)RUNTIME_CLASS(CSheetFormView)->CreateObject(); if (!m_pSheet7 || !((CWnd*)m_pSheet7) ->Create(NULL, NULL, WS_CHILD, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET7, &cc)) { TRACE(_T("ERROR: Unable to create sheet7.\n")); return FALSE; } return TRUE; } BOOL CExcelTabDlg::CreateSheet8() { // Create the Test Scroll View CCreateContext cc; ::ZeroMemory(&cc, sizeof(cc)); cc.m_pCurrentDoc = NULL; m_pSheet8 = (CSheetScrollView*)RUNTIME_CLASS(CSheetScrollView)->CreateObject(); if (!m_pSheet8 || !((CWnd*)m_pSheet8) ->Create(NULL, NULL, WS_CHILD | WS_VSCROLL | WS_HSCROLL, CXTPEmptyRect(), m_pExcelTabCtrl, IDC_SHEET8, &cc)) { TRACE(_T("ERROR: Unable to create sheet8.\n")); return FALSE; } return TRUE; } void CExcelTabDlg::OnProperties() { CExcelTabProperties dlg(m_bBottom, m_bHasArrows, m_bHasHomeEnd, m_bHScroll, m_bSquareTabs, this); dlg.DoModal(); } void CExcelTabDlg::UpdateExcelTabCtrl() { UpdateExcelTabCtrlStyle(); m_pExcelTabCtrl->SetTabStyle(m_dwTabStyle); } void CExcelTabDlg::UpdateExcelTabCtrlStyle() { DWORD dwNewStyle = 0; if (m_bHasHomeEnd) { dwNewStyle |= FTS_XTP_HASHOMEEND; m_bHasArrows = TRUE; } if (m_bBottom) dwNewStyle |= FTS_XTP_BOTTOM; if (m_bHasArrows) dwNewStyle |= FTS_XTP_HASARROWS; if (m_bHScroll) dwNewStyle |= FTS_XTP_HSCROLL; if (m_bSquareTabs) dwNewStyle |= FTS_XTP_SQUARETABS; dwNewStyle |= FTS_XTP_TOOLTIPS; if (dwNewStyle != m_dwTabStyle) { m_dwTabStyle = dwNewStyle; } } BOOL CExcelTabDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if (IDC_EXCELTAB_CTRL == (UINT)wParam) { NMHDR* pNMHDR = (NMHDR*)lParam; switch (pNMHDR->code) { case TCN_SELCHANGING: break; case TCN_SELCHANGE: // For unmanaged views, you can use something like this: // SelectTabView(m_pFlatTabCtrl->GetCurSel()); break; } } return CXTPResizeDialog::OnNotify(wParam, lParam, pResult); } LRESULT CExcelTabDlg::OnSetControlTheme(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); XTPControlTheme nTheme = (XTPControlTheme)wParam; if (nTheme >= xtpControlThemeOffice2013) { m_bSquareTabs = TRUE; m_pExcelTabCtrl->SetTabHeight(XTP_DPI_Y(25)); } else { m_bSquareTabs = FALSE; m_pExcelTabCtrl->SetTabHeight(::GetSystemMetrics(SM_CYHSCROLL)); } return 0; } void CExcelTabDlg::InitThemeDlg() { m_dlgTheme.ExcludeTheme(XTP_EXCLUDE_THEME_CUSTOM | XTP_EXCLUDE_THEME_VISUALSTUDIO6 | XTP_EXCLUDE_THEME_VISUALSTUDIO2012); VERIFY(m_dlgTheme.Create(IDD_THEME_DIALOG, this)); m_dlgTheme.SetTheme(xtpThemeDlgOffice2016, xtpThemeColor2016Colorful, xtpThemeAccentExcel, xtpThemeRibbonBackUndef, TRUE); m_dlgTheme.EnableAutoPreview(TRUE); m_dlgTheme.InsertAfter(_T("Native Windows 11"), xtpThemeDlgCustom + 1, _T("Default")); m_dlgTheme.InsertAfter(_T("Default"), xtpThemeDlgCustom + 2, _T("Flat")); m_dlgTheme.InsertAfter(_T("Flat"), xtpThemeDlgCustom + 3, _T("Ultra Flat")); } void CExcelTabDlg::OnThemeDlg() { m_dlgTheme.ShowWindow(SW_SHOW); } LRESULT CExcelTabDlg::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)); m_bEnableDefault = FALSE; m_bEnableFlat = FALSE; m_bEnableUltraFlat = FALSE; switch (nTheme) { case xtpThemeDlgOffice2000: theApp.SetAppTheme(xtpThemeOffice2000); break; case xtpThemeDlgOfficeXP: theApp.SetAppTheme(xtpThemeOfficeXP); break; case xtpThemeDlgOffice2003: theApp.SetAppTheme(xtpThemeOffice2003); break; case xtpThemeDlgOffice2007: { switch (nColor) { case xtpThemeColor2007Blue: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Blue); break; case xtpThemeColor2007Silver: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Silver); break; case xtpThemeColor2007Black: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Black); break; case xtpThemeColor2007Aqua: theApp.SetAppTheme(xtpThemeOffice2007, xtpIniOffice2007Aqua); break; case xtpThemeColor2007System: theApp.SetAppTheme(xtpThemeOffice2007System); break; } } break; case xtpThemeDlgOffice2010: { switch (nColor) { case xtpThemeColor2010Blue: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Blue); break; case xtpThemeColor2010Silver: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Silver); break; case xtpThemeColor2010Black: theApp.SetAppTheme(xtpThemeResource, xtpIniOffice2010Black); break; } } break; case xtpThemeDlgOffice2013: { switch (nColor) { case xtpThemeColor2013White: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Access); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Excel); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNote); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Outlook); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPoint); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Publisher); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013Word); break; } } break; case xtpThemeColor2013GrayLight: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013AccessGrayLight); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013ExcelGrayLight); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNoteGrayLight); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OutlookGrayLight); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPointGrayLight); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PublisherGrayLight); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013WordGrayLight); break; } } break; case xtpThemeColor2013GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013AccessGrayDark); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013ExcelGrayDark); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OneNoteGrayDark); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013OutlookGrayDark); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PowerPointGrayDark); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013PublisherGrayDark); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2013, xtpIniOffice2013WordGrayDark); break; } } break; } } break; case xtpThemeDlgOffice2016: { switch (nColor) { case xtpThemeColor2016Black: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessBlack); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelBlack); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteBlack); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookBlack); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointBlack); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherBlack); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordBlack); break; } } break; case xtpThemeColor2016White: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessWhite); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelWhite); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteWhite); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookWhite); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointWhite); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherWhite); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordWhite); break; } } break; case xtpThemeColor2016Colorful: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessColorful); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelColorful); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteColorful); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookColorful); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointColorful); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherColorful); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordColorful); break; } } break; case xtpThemeColor2016GrayDark: { switch (nAccent) { case xtpThemeAccentAccess: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016AccessDarkGray); break; case xtpThemeAccentExcel: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016ExcelDarkGray); break; case xtpThemeAccentOneNote: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OneNoteDarkGray); break; case xtpThemeAccentOutlook: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016OutlookDarkGray); break; case xtpThemeAccentPowerPoint: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PowerPointDarkGray); break; case xtpThemeAccentPublisher: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016PublisherDarkGray); break; case xtpThemeAccentWord: theApp.SetAppTheme(xtpThemeOffice2016, xtpIniOffice2016WordDarkGray); break; } } break; } } break; case xtpThemeDlgVisualStudio6: theApp.SetAppTheme(xtpThemeVisualStudio6); break; case xtpThemeDlgVisualStudio2005: theApp.SetAppTheme(xtpThemeVisualStudio2005); break; case xtpThemeDlgVisualStudio2008: theApp.SetAppTheme(xtpThemeVisualStudio2008); break; case xtpThemeDlgVisualStudio2010: theApp.SetAppTheme(xtpThemeVisualStudio2010); break; case xtpThemeDlgVisualStudio2015: { switch (nColor) { case xtpThemeColor2015Blue: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Blue); break; case xtpThemeColor2015Dark: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Dark); break; case xtpThemeColor2015Light: theApp.SetAppTheme(xtpThemeVisualStudio2015, xtpIniVisualStudio2015Light); break; } } break; case xtpThemeDlgVisualStudio2017: { switch (nColor) { case xtpThemeColor2017Blue: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Blue); break; case xtpThemeColor2017BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017BlueExtra); break; case xtpThemeColor2017Dark: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Dark); break; case xtpThemeColor2017Light: theApp.SetAppTheme(xtpThemeVisualStudio2017, xtpIniVisualStudio2017Light); break; } } break; case xtpThemeDlgVisualStudio2019: { switch (nColor) { case xtpThemeColor2019Blue: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Blue); break; case xtpThemeColor2019BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019BlueExtra); break; case xtpThemeColor2019Dark: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Dark); break; case xtpThemeColor2019Light: theApp.SetAppTheme(xtpThemeVisualStudio2019, xtpIniVisualStudio2019Light); break; } } break; case xtpThemeDlgVisualStudio2022: { switch (nColor) { case xtpThemeColor2022Blue: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Blue); break; case xtpThemeColor2022BlueExtra: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022BlueExtra); break; case xtpThemeColor2022Dark: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Dark); break; case xtpThemeColor2022Light: theApp.SetAppTheme(xtpThemeVisualStudio2022, xtpIniVisualStudio2022Light); break; } } break; case xtpThemeDlgNativeWindows: theApp.SetAppTheme(xtpThemeResource, xtpIniWindows7Blue); break; case xtpThemeDlgNativeWindows10: { switch (nColor) { case xtpThemeColorWindows10Light: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); theApp.SetAppTheme(xtpThemeNativeWindows10, xtpIniWindows10Light); break; case xtpThemeColorWindows10Dark: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, static_cast( pThemeColor->nAccent)); theApp.SetAppTheme(xtpThemeNativeWindows10, xtpIniWindows10Dark); break; } } break; case xtpThemeDlgNativeWindows11: { switch (nColor) { case xtpThemeColorWindows11Light: theApp.SetAppTheme(xtpThemeNativeWindows11, xtpIniWindows11Light); break; case xtpThemeColorWindows11Dark: theApp.SetAppTheme(xtpThemeNativeWindows11, xtpIniWindows11Dark); break; } } break; case xtpThemeDlgCustom + 1: // Default m_bEnableDefault = TRUE; theApp.SetAppTheme(xtpThemeCustom); break; case xtpThemeDlgCustom + 2: // Flat m_bEnableFlat = TRUE; theApp.SetAppTheme(xtpThemeCustom); break; case xtpThemeDlgCustom + 3: // Ultra Flat m_bEnableUltraFlat = TRUE; theApp.SetAppTheme(xtpThemeCustom); break; } UpdateTheme(); return 0; } void CExcelTabDlg::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; SendMessage(WM_NCPAINT); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_ERASE); } void CExcelTabDlg::EnableTheme(XTPPaintTheme nTheme, LPCTSTR lpzThemeSettings, BOOL bEnable /*= TRUE*/) { ASSERT(NULL != lpzThemeSettings); switch (nTheme) { case xtpThemeNone: EnableNoStyle(bEnable); break; case xtpThemeDlgOffice2000: EnableStyleOffice2000(); break; case xtpThemeDlgOfficeXP: EnableStyleOfficeXP(); break; case xtpThemeDlgOffice2003: EnableStyleOffice2003(); break; case xtpThemeOffice2013: if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2013"))) { EnableStyleOffice2013(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2016"))) { EnableStyleOffice2016(bEnable); } else { ASSERT(!"Unexpected theme settings"); } break; case xtpThemeVisualStudio2005: EnableStyleVisualStudio2005(bEnable); break; case xtpThemeVisualStudio2008: EnableStyleVisualStudio2008(bEnable); break; case xtpThemeVisualStudio2010: EnableStyleVisualStudio2010(bEnable); break; case xtpThemeVisualStudio2015: EnableStyleVisualStudio2015(bEnable); break; case xtpThemeVisualStudio2017: EnableStyleVisualStudio2017(bEnable); break; case xtpThemeVisualStudio2019: EnableStyleVisualStudio2019(bEnable); break; case xtpThemeVisualStudio2022: EnableStyleVisualStudio2022(bEnable); break; case xtpThemeNativeWindows10: EnableStyleWindows10(bEnable); break; case xtpThemeNativeWindows11: EnableStyleWindows11(bEnable); break; case xtpThemeResource: if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2007"))) { EnableStyleOffice2007(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("OFFICE2010"))) { EnableStyleOffice2010(bEnable); } else if (0 < _tcsstr(lpzThemeSettings, _T("WINDOWS7"))) { EnableStyleWindows7(bEnable); } else { ASSERT(!"Unexpected theme settings"); } break; case xtpThemeOffice2007System: EnableStyleOffice2007System(bEnable); break; case xtpThemeCustom: EnableStyleCustom(); break; default: ASSERT(!"Unsupported theme"); break; } UpdateColors(); } void CExcelTabDlg::UpdateColors(BOOL bLoadIni /*=TRUE*/) { if (bLoadIni) { theApp.m_clrText = XTPIniColor(_T("Controls.Button"), _T("Text"), ::GetSysColor(COLOR_BTNTEXT)); theApp.m_clrBack = XTPIniColor(_T("Controls.Button"), _T("Back"), ::GetSysColor(COLOR_BTNFACE)); } else { theApp.m_clrText = ::GetSysColor(COLOR_BTNTEXT); theApp.m_clrBack = ::GetSysColor(COLOR_BTNFACE); } theApp.m_clrEdge = theApp.m_clrBack; theApp.m_brBack.DeleteObject(); theApp.m_brBack.CreateSolidBrush(theApp.m_clrBack); if (IsWindow(m_sheet1.GetSafeHwnd())) m_sheet1.SetRowColors(theApp.m_clrText, theApp.m_clrBack); } void CExcelTabDlg::DisableStyle() { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); } void CExcelTabDlg::EnableNoStyle(BOOL bEnable /*= TRUE*/) { UNREFERENCED_PARAMETER(bEnable); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); } void CExcelTabDlg::EnableStyleOffice2000(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOffice2000); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOfficeXP(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOfficeXP); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2003(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOffice2003); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2007(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeResource); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2007System(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeResource); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeResource); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2013(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOffice2013); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleOffice2016(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOffice2016); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2005(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2005); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2008(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2008); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2010(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2010); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2015(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2015); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2017(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2017); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2019(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2019); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleVisualStudio2022(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeVisualStudio2022); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleWindows7(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeNativeWinXP); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleWindows10(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeNativeWindows10); // TODO: Leave COLORREF_NULL as an accent color to get system accent color // or specify any custom RGB accent color value. XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, COleVariant(static_cast(COLORREF_NULL), VT_I4)); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleWindows11(BOOL bEnable /*= TRUE*/) { if (bEnable) { SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeNativeWindows11); } else { DisableStyle(); } } void CExcelTabDlg::EnableStyleCustom(BOOL bEnable /*= TRUE*/) { if (bEnable) { if (m_bEnableDefault) SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); if (m_bEnableFlat) SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeFlat); if (m_bEnableUltraFlat) SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeUltraFlat); } else { DisableStyle(); } }