/** * @file XTPMarkupDelegate.cpp * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #include "stdafx.h" #include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" #include #include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" #include "Common/XTPCasting.h" #include "Common/XTPTypeId.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Markup/XTPMarkupObject.h" #include "Markup/XTPMarkupDelegate.h" #include "Markup/XTPMarkupRoutedEventArgs.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # undef THIS_FILE static char THIS_FILE[] = __FILE__; # define new DEBUG_NEW #endif /////////////////////////////////////////////////////////////////////////////// // CXTPMarkupDelegate IMPLEMENT_DYNAMIC(CXTPMarkupDelegate, CXTPMarkupObject); CXTPMarkupDelegate::CXTPMarkupDelegate() : CXTPMarkupObject(flagNoCom) { } void CXTPMarkupDelegate::Execute(CXTPMarkupObject* /*pSender*/, CXTPMarkupRoutedEventArgs* /*pArgs*/) { _ASSERTE(FALSE); } /////////////////////////////////////////////////////////////////////////////// // CXTPMarkupFunctionDelegate IMPLEMENT_DYNAMIC(CXTPMarkupFunctionDelegate, CXTPMarkupDelegate); CXTPMarkupFunctionDelegate::CXTPMarkupFunctionDelegate(ROUTEDEVENTHANDLER pHandler) : m_pHandler(pHandler) { _ASSERTE(NULL != pHandler); } void CXTPMarkupFunctionDelegate::Execute(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs) { (*m_pHandler)(pSender, pArgs); } /////////////////////////////////////////////////////////////////////////////// // CXTPMarkupDispatchDelegate IMPLEMENT_DYNAMIC(CXTPMarkupDispatchDelegate, CXTPMarkupDelegate); CXTPMarkupDispatchDelegate::CXTPMarkupDispatchDelegate(IDispatch* pDisp) : m_pDisp(pDisp) { _ASSERTE(NULL != pDisp); m_pDisp->AddRef(); } CXTPMarkupDispatchDelegate::~CXTPMarkupDispatchDelegate() { m_pDisp->Release(); } IDispatch* CXTPMarkupDispatchDelegate::GetDelegateDispatch(BOOL bAddRef /*= TRUE*/) const { if (bAddRef) m_pDisp->AddRef(); return m_pDisp; } void CXTPMarkupDispatchDelegate::Execute(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs) { UNREFERENCED_PARAMETER(pSender); _ASSERTE(NULL != pSender); _ASSERTE(NULL != pArgs); DISPPARAMS dp = { 0 }; COleVariant vtResult; if (FAILED(m_pDisp->Invoke(DISPID_VALUE, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dp, &vtResult, NULL, NULL))) return; if (VT_BOOL == vtResult.vt && vtResult.boolVal == -1 /*VARIANT_TRUE*/) pArgs->SetHandled(); }