// // modified SAFEARRAY parameter by hand #pragma once template class CProxy_IGainerEvents : public IConnectionPointImpl { public: HRESULT Fire_ButtonPressed() { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { DISPPARAMS params = { NULL, NULL, 0, 0 }; hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_ButtonReleased() { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { DISPPARAMS params = { NULL, NULL, 0, 0 }; hr = pConnection->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_DigitalInputs(SAFEARRAY* NewValue) { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { CComVariant avarParams[1]; avarParams[0].pparray = &NewValue; avarParams[0].vt = VT_BYREF | VT_ARRAY | VT_UI1; DISPPARAMS params = { avarParams, NULL, 1, 0 }; hr = pConnection->Invoke(3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_AnalogInputs(SAFEARRAY* NewValue) { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { CComVariant avarParams[1]; avarParams[0].pparray = &NewValue; avarParams[0].vt = VT_BYREF | VT_ARRAY | VT_UI1; DISPPARAMS params = { avarParams, NULL, 1, 0 }; hr = pConnection->Invoke(4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_AnalogInput( long NewValue) { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { CComVariant avarParams[1]; avarParams[0] = NewValue; avarParams[0].vt = VT_I4; DISPPARAMS params = { avarParams, NULL, 1, 0 }; hr = pConnection->Invoke(5, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_Error( long Code) { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { CComVariant avarParams[1]; avarParams[0] = Code; avarParams[0].vt = VT_I4; DISPPARAMS params = { avarParams, NULL, 1, 0 }; hr = pConnection->Invoke(6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } HRESULT Fire_Rebooted() { HRESULT hr = S_OK; T * pThis = static_cast(this); int cConnections = m_vec.GetSize(); for (int iConnection = 0; iConnection < cConnections; iConnection++) { pThis->Lock(); CComPtr punkConnection = m_vec.GetAt(iConnection); pThis->Unlock(); IDispatch * pConnection = static_cast(punkConnection.p); if (pConnection) { DISPPARAMS params = { NULL, NULL, 0, 0 }; hr = pConnection->Invoke(7, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } } return hr; } };