// ActionsSampleView.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 "ActionsSample.h" #include "MainFrm.h" #include "ActionsSampleDoc.h" #include "CntrItem.h" #include "ActionsSampleView.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CActionsSampleView IMPLEMENT_DYNCREATE(CActionsSampleView, CRichEditView) BEGIN_MESSAGE_MAP(CActionsSampleView, CRichEditView) //{{AFX_MSG_MAP(CActionsSampleView) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! ON_WM_DESTROY() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview) ON_NOTIFY_REFLECT(EN_SELCHANGE, OnSelChange) ON_COMMAND(ID_CHAR_BOLD, OnCharBold) ON_COMMAND(ID_CHAR_ITALIC, OnCharItalic) ON_COMMAND(ID_CHAR_UNDERLINE, OnCharUnderline) ON_COMMAND(ID_PARA_CENTER, CRichEditView::OnParaCenter) ON_UPDATE_COMMAND_UI(ID_PARA_CENTER, CRichEditView::OnUpdateParaCenter) ON_COMMAND(ID_PARA_LEFT, CRichEditView::OnParaLeft) ON_UPDATE_COMMAND_UI(ID_PARA_LEFT, CRichEditView::OnUpdateParaLeft) ON_COMMAND(ID_PARA_RIGHT, CRichEditView::OnParaRight) ON_UPDATE_COMMAND_UI(ID_PARA_RIGHT, CRichEditView::OnUpdateParaRight) #define IMPLEMENT_APPTHEME_MAP(ID, Theme) \ ON_COMMAND(ID_OPTIONS_STYLE_##ID, OnViewTheme##Theme) \ ON_UPDATE_COMMAND_UI(ID_OPTIONS_STYLE_##ID, OnUpdateViewTheme##Theme) IMPLEMENT_APPTHEME_MAP(OFFICE2000, Office2000) IMPLEMENT_APPTHEME_MAP(OFFICEXP, OfficeXP) IMPLEMENT_APPTHEME_MAP(OFFICE2003, Office2003) IMPLEMENT_APPTHEME_MAP(WINDOWSXP, WindowsXP) IMPLEMENT_APPTHEME_MAP(RIBBON, Ribbon) IMPLEMENT_APPTHEME_MAP(OFFICE2007AQUA, Office2007Aqua) IMPLEMENT_APPTHEME_MAP(OFFICE2007BLACK, Office2007Black) IMPLEMENT_APPTHEME_MAP(OFFICE2007BLUE, Office2007Blue) IMPLEMENT_APPTHEME_MAP(OFFICE2007SILVER, Office2007Silver) IMPLEMENT_APPTHEME_MAP(OFFICE2007SYSTEM, Office2007System) IMPLEMENT_APPTHEME_MAP(OFFICE2010BLACK, Office2010Black) IMPLEMENT_APPTHEME_MAP(OFFICE2010BLUE, Office2010Blue) IMPLEMENT_APPTHEME_MAP(OFFICE2010SILVER, Office2010Silver) IMPLEMENT_APPTHEME_MAP(OFFICE2013WORD, Office2013Word) IMPLEMENT_APPTHEME_MAP(OFFICE2013EXCEL, Office2013Excel) IMPLEMENT_APPTHEME_MAP(OFFICE2013ACCESS, Office2013Access) IMPLEMENT_APPTHEME_MAP(OFFICE2013POWERPOINT, Office2013Powerpoint) IMPLEMENT_APPTHEME_MAP(OFFICE2013ONENOTE, Office2013OneNote) IMPLEMENT_APPTHEME_MAP(OFFICE2013OUTLOOK, Office2013Outlook) IMPLEMENT_APPTHEME_MAP(WINDOWS7SCENIC, Windows7) IMPLEMENT_APPTHEME_MAP(WINDOWS10LIGHT, Windows10Light) IMPLEMENT_APPTHEME_MAP(WINDOWS10DARK, Windows10Dark) IMPLEMENT_APPTHEME_MAP(WINDOWS11LIGHT, Windows11Light) IMPLEMENT_APPTHEME_MAP(WINDOWS11DARK, Windows11Dark) IMPLEMENT_APPTHEME_MAP(VC6, VisualStudio6) IMPLEMENT_APPTHEME_MAP(VC8, VisualStudio8) IMPLEMENT_APPTHEME_MAP(VC9, VisualStudio9) IMPLEMENT_APPTHEME_MAP(VC10, VisualStudio10) IMPLEMENT_APPTHEME_MAP(VC11_LIGHT, VisualStudio2012Light) IMPLEMENT_APPTHEME_MAP(VC11_DARK, VisualStudio2012Dark) IMPLEMENT_APPTHEME_MAP(VC14_LIGHT, VisualStudio2015Light) IMPLEMENT_APPTHEME_MAP(VC14_BLUE, VisualStudio2015Blue) IMPLEMENT_APPTHEME_MAP(VC14_DARK, VisualStudio2015Dark) IMPLEMENT_APPTHEME_MAP(VC15_BLUE, VisualStudio2017Blue) IMPLEMENT_APPTHEME_MAP(VC15_BLUE_EXTRA, VisualStudio2017BlueExtra) IMPLEMENT_APPTHEME_MAP(VC15_LIGHT, VisualStudio2017Light) IMPLEMENT_APPTHEME_MAP(VC15_DARK, VisualStudio2017Dark) IMPLEMENT_APPTHEME_MAP(VC16_BLUE, VisualStudio2019Blue) IMPLEMENT_APPTHEME_MAP(VC16_BLUE_EXTRA, VisualStudio2019BlueExtra) IMPLEMENT_APPTHEME_MAP(VC16_LIGHT, VisualStudio2019Light) IMPLEMENT_APPTHEME_MAP(VC16_DARK, VisualStudio2019Dark) IMPLEMENT_APPTHEME_MAP(VC17_BLUE, VisualStudio2022Blue) IMPLEMENT_APPTHEME_MAP(VC17_BLUE_EXTRA, VisualStudio2022BlueExtra) IMPLEMENT_APPTHEME_MAP(VC17_LIGHT, VisualStudio2022Light) IMPLEMENT_APPTHEME_MAP(VC17_DARK, VisualStudio2022Dark) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CActionsSampleView construction/destruction CActionsSampleView::CActionsSampleView() { // TODO: add construction code here } CActionsSampleView::~CActionsSampleView() { } BOOL CActionsSampleView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CRichEditView::PreCreateWindow(cs); } void CActionsSampleView::OnInitialUpdate() { CRichEditView::OnInitialUpdate(); USES_CONVERSION; // Set the printing margins (720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); SetSampleDescriptionText( GetRichEditCtrl(), _T("This sample demonstrates how to manage CommansBars actions. The Actions panel on the ") _T("right side allows changing state and properties of a selected action ") _T("as well as saving and loading the entire CommandBars state into a file. The changes ") _T("will be reflected in the menus and toolbars immediately.")); } ///////////////////////////////////////////////////////////////////////////// // CActionsSampleView printing BOOL CActionsSampleView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CActionsSampleView::OnDestroy() { // Force release the internal OLE callback in order to avoid a memory leak. GetRichEditCtrl().SetOLECallback(NULL); CRichEditView::OnDestroy(); } ///////////////////////////////////////////////////////////////////////////// // CActionsSampleView diagnostics #ifdef _DEBUG void CActionsSampleView::AssertValid() const { CRichEditView::AssertValid(); } void CActionsSampleView::Dump(CDumpContext& dc) const { CRichEditView::Dump(dc); } CActionsSampleDoc* CActionsSampleView::GetDocument() // non-debug version is inline { _ASSERTE(m_pDocument->IsKindOf(RUNTIME_CLASS(CActionsSampleDoc))); return (CActionsSampleDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CActionsSampleView message handlers void CActionsSampleView::OnCharBold() { CRichEditView::OnCharBold(); UpdateActionsState(); } void CActionsSampleView::OnCharItalic() { CRichEditView::OnCharItalic(); UpdateActionsState(); } void CActionsSampleView::OnCharUnderline() { CRichEditView::OnCharUnderline(); UpdateActionsState(); } void CActionsSampleView::OnSelChange(NMHDR* pNMHDR, LRESULT* pResult) { CRichEditView::OnSelChange(pNMHDR, pResult); UpdateActionsState(); } void CActionsSampleView::UpdateActionsState() { CHARFORMAT& cfm = GetCharFormatSelection(); CXTPCommandBars* pCommandBars = ((CXTPFrameWnd*)GetParentFrame())->GetCommandBars(); pCommandBars->GetActions() ->FindAction(ID_CHAR_BOLD) ->SetChecked((cfm.dwMask & CFM_BOLD ? (cfm.dwEffects & CFE_BOLD ? 1 : 0) : 2)); pCommandBars->GetActions() ->FindAction(ID_CHAR_ITALIC) ->SetChecked((cfm.dwMask & CFM_ITALIC ? (cfm.dwEffects & CFE_ITALIC ? 1 : 0) : 2)); pCommandBars->GetActions() ->FindAction(ID_CHAR_UNDERLINE) ->SetChecked((cfm.dwMask & CFM_UNDERLINE ? (cfm.dwEffects & CFE_UNDERLINE ? 1 : 0) : 2)); } #define IMPLEMENT_APPTHEME(Theme) \ void CActionsSampleView::OnViewTheme##Theme() \ { \ SetTheme(CActionsSampleApp::theme##Theme); \ } \ void CActionsSampleView::OnUpdateViewTheme##Theme(CCmdUI* pCmdUI) \ { \ pCmdUI->SetCheck(CActionsSampleApp::theme##Theme == theApp.m_theme ? 1 : 0); \ } IMPLEMENT_APPTHEME(Office2000) IMPLEMENT_APPTHEME(OfficeXP) IMPLEMENT_APPTHEME(Office2003) IMPLEMENT_APPTHEME(WindowsXP) IMPLEMENT_APPTHEME(Ribbon) IMPLEMENT_APPTHEME(Office2007Aqua) IMPLEMENT_APPTHEME(Office2007Black) IMPLEMENT_APPTHEME(Office2007Blue) IMPLEMENT_APPTHEME(Office2007Silver) IMPLEMENT_APPTHEME(Office2007System) IMPLEMENT_APPTHEME(Office2010Black) IMPLEMENT_APPTHEME(Office2010Blue) IMPLEMENT_APPTHEME(Office2010Silver) IMPLEMENT_APPTHEME(Office2013Word) IMPLEMENT_APPTHEME(Office2013Excel) IMPLEMENT_APPTHEME(Office2013Access) IMPLEMENT_APPTHEME(Office2013Powerpoint) IMPLEMENT_APPTHEME(Office2013OneNote) IMPLEMENT_APPTHEME(Office2013Outlook) IMPLEMENT_APPTHEME(Windows7) IMPLEMENT_APPTHEME(Windows10Light) IMPLEMENT_APPTHEME(Windows10Dark) IMPLEMENT_APPTHEME(Windows11Light) IMPLEMENT_APPTHEME(Windows11Dark) IMPLEMENT_APPTHEME(VisualStudio6) IMPLEMENT_APPTHEME(VisualStudio8) IMPLEMENT_APPTHEME(VisualStudio9) IMPLEMENT_APPTHEME(VisualStudio10) IMPLEMENT_APPTHEME(VisualStudio2012Light) IMPLEMENT_APPTHEME(VisualStudio2012Dark) IMPLEMENT_APPTHEME(VisualStudio2015Light) IMPLEMENT_APPTHEME(VisualStudio2015Blue) IMPLEMENT_APPTHEME(VisualStudio2015Dark) IMPLEMENT_APPTHEME(VisualStudio2017Blue) IMPLEMENT_APPTHEME(VisualStudio2017BlueExtra) IMPLEMENT_APPTHEME(VisualStudio2017Light) IMPLEMENT_APPTHEME(VisualStudio2017Dark) IMPLEMENT_APPTHEME(VisualStudio2019Blue) IMPLEMENT_APPTHEME(VisualStudio2019BlueExtra) IMPLEMENT_APPTHEME(VisualStudio2019Light) IMPLEMENT_APPTHEME(VisualStudio2019Dark) IMPLEMENT_APPTHEME(VisualStudio2022Blue) IMPLEMENT_APPTHEME(VisualStudio2022BlueExtra) IMPLEMENT_APPTHEME(VisualStudio2022Light) IMPLEMENT_APPTHEME(VisualStudio2022Dark) void CActionsSampleView::SetTheme(CActionsSampleApp::AppTheme theme, BOOL bRedraw /*=TRUE*/) { theApp.m_theme = theme; CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, theApp.m_pMainWnd); ASSERT_VALID(pMainFrame); if (!pMainFrame) return; if (bRedraw == FALSE) { pMainFrame->SetRedraw(FALSE); } switch (theme) { case CActionsSampleApp::themeOffice2000: pMainFrame->SetTheme(xtpThemeOffice2000); break; case CActionsSampleApp::themeOfficeXP: pMainFrame->SetTheme(xtpThemeOfficeXP); break; case CActionsSampleApp::themeOffice2003: pMainFrame->SetTheme(xtpThemeOffice2003); break; case CActionsSampleApp::themeWindowsXP: pMainFrame->SetTheme(xtpThemeNativeWinXP); break; case CActionsSampleApp::themeRibbon: pMainFrame->SetTheme(xtpThemeRibbon); break; case CActionsSampleApp::themeOffice2007Aqua: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2007, xtpIniOffice2007Aqua); break; case CActionsSampleApp::themeOffice2007Black: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2007, xtpIniOffice2007Black); break; case CActionsSampleApp::themeOffice2007Blue: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2007, xtpIniOffice2007Blue); break; case CActionsSampleApp::themeOffice2007Silver: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2007, xtpIniOffice2007Silver); break; case CActionsSampleApp::themeOffice2007System: pMainFrame->SetTheme(xtpThemeOffice2007System); break; case CActionsSampleApp::themeOffice2010Black: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2010, xtpIniOffice2010Black); break; case CActionsSampleApp::themeOffice2010Blue: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2010, xtpIniOffice2010Blue); break; case CActionsSampleApp::themeOffice2010Silver: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModule2010, xtpIniOffice2010Silver); break; case CActionsSampleApp::themeOffice2013Word: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013Word); break; case CActionsSampleApp::themeOffice2013Excel: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013Excel); break; case CActionsSampleApp::themeOffice2013Access: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013Access); break; case CActionsSampleApp::themeOffice2013Powerpoint: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013PowerPoint); break; case CActionsSampleApp::themeOffice2013OneNote: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013OneNote); break; case CActionsSampleApp::themeOffice2013Outlook: pMainFrame->SetTheme(xtpThemeOffice2013, theApp.m_hModule2013, xtpIniOffice2013Outlook); break; case CActionsSampleApp::themeWindows7: pMainFrame->SetTheme(xtpThemeRibbon, theApp.m_hModuleWindows7, xtpIniWindows7Blue); break; case CActionsSampleApp::themeWindows10Light: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, LONG(RGB(150, 150, 150))); pMainFrame->SetTheme(xtpThemeNativeWindows10, theApp.m_hModuleWindows10, xtpIniWindows10Light); break; case CActionsSampleApp::themeWindows10Dark: XTPGetApplication()->SetAmbientProperty(xtpApplicationAccentColor, LONG(RGB(200, 50, 50))); pMainFrame->SetTheme(xtpThemeNativeWindows10, theApp.m_hModuleWindows10, xtpIniWindows10Dark); break; case CActionsSampleApp::themeWindows11Light: pMainFrame->SetTheme(xtpThemeNativeWindows11, theApp.m_hModuleWindows11, xtpIniWindows11Light); break; case CActionsSampleApp::themeWindows11Dark: pMainFrame->SetTheme(xtpThemeNativeWindows11, theApp.m_hModuleWindows11, xtpIniWindows11Dark); break; case CActionsSampleApp::themeVisualStudio6: pMainFrame->SetTheme(xtpThemeVisualStudio6); break; case CActionsSampleApp::themeVisualStudio8: pMainFrame->SetTheme(xtpThemeVisualStudio2005); break; case CActionsSampleApp::themeVisualStudio9: pMainFrame->SetTheme(xtpThemeVisualStudio2008); break; case CActionsSampleApp::themeVisualStudio10: pMainFrame->SetTheme(xtpThemeVisualStudio2010); break; case CActionsSampleApp::themeVisualStudio2012Dark: pMainFrame->SetTheme(xtpThemeVisualStudio2012Dark, theApp.m_hModule2012, xtpIniVisualStudio2012Dark); break; case CActionsSampleApp::themeVisualStudio2012Light: pMainFrame->SetTheme(xtpThemeVisualStudio2012Light, theApp.m_hModule2012, xtpIniVisualStudio2012Light); break; case CActionsSampleApp::themeVisualStudio2015Light: pMainFrame->SetTheme(xtpThemeVisualStudio2015, theApp.m_hModule2015, xtpIniVisualStudio2015Light); break; case CActionsSampleApp::themeVisualStudio2015Blue: pMainFrame->SetTheme(xtpThemeVisualStudio2015, theApp.m_hModule2015, xtpIniVisualStudio2015Blue); break; case CActionsSampleApp::themeVisualStudio2015Dark: pMainFrame->SetTheme(xtpThemeVisualStudio2015, theApp.m_hModule2015, xtpIniVisualStudio2015Dark); break; case CActionsSampleApp::themeVisualStudio2017Blue: pMainFrame->SetTheme(xtpThemeVisualStudio2017, theApp.m_hModule2017, xtpIniVisualStudio2017Blue); break; case CActionsSampleApp::themeVisualStudio2017BlueExtra: pMainFrame->SetTheme(xtpThemeVisualStudio2017, theApp.m_hModule2017, xtpIniVisualStudio2017BlueExtra); break; case CActionsSampleApp::themeVisualStudio2017Light: pMainFrame->SetTheme(xtpThemeVisualStudio2017, theApp.m_hModule2017, xtpIniVisualStudio2017Light); break; case CActionsSampleApp::themeVisualStudio2017Dark: pMainFrame->SetTheme(xtpThemeVisualStudio2017, theApp.m_hModule2017, xtpIniVisualStudio2017Dark); break; case CActionsSampleApp::themeVisualStudio2019Blue: pMainFrame->SetTheme(xtpThemeVisualStudio2019, theApp.m_hModule2019, xtpIniVisualStudio2019Blue); break; case CActionsSampleApp::themeVisualStudio2019BlueExtra: pMainFrame->SetTheme(xtpThemeVisualStudio2019, theApp.m_hModule2019, xtpIniVisualStudio2019BlueExtra); break; case CActionsSampleApp::themeVisualStudio2019Light: pMainFrame->SetTheme(xtpThemeVisualStudio2019, theApp.m_hModule2019, xtpIniVisualStudio2019Light); break; case CActionsSampleApp::themeVisualStudio2019Dark: pMainFrame->SetTheme(xtpThemeVisualStudio2019, theApp.m_hModule2019, xtpIniVisualStudio2019Dark); break; case CActionsSampleApp::themeVisualStudio2022Blue: pMainFrame->SetTheme(xtpThemeVisualStudio2022, theApp.m_hModule2022, xtpIniVisualStudio2022Blue); break; case CActionsSampleApp::themeVisualStudio2022BlueExtra: pMainFrame->SetTheme(xtpThemeVisualStudio2022, theApp.m_hModule2022, xtpIniVisualStudio2022BlueExtra); break; case CActionsSampleApp::themeVisualStudio2022Light: pMainFrame->SetTheme(xtpThemeVisualStudio2022, theApp.m_hModule2022, xtpIniVisualStudio2022Light); break; case CActionsSampleApp::themeVisualStudio2022Dark: pMainFrame->SetTheme(xtpThemeVisualStudio2022, theApp.m_hModule2022, xtpIniVisualStudio2022Dark); break; } if (bRedraw == FALSE) { pMainFrame->SetRedraw(TRUE); } }