////////////////////////////////////////////////////////////////////////////// // CProxy_GlassEvents template <class T> class CProxy_GlassEvents : public IConnectionPointImpl<T, &DIID__GlassEvents, CComDynamicUnkArray> { public: //methods: //_GlassEvents : IDispatch public: void OnMouseDown( short Button, short Shift, long x, long y) { VARIANTARG* pvars = new VARIANTARG[4]; for (int i = 0; i < 4; i++) VariantInit(&pvars[i]); T* pT = (T*)this; pT->Lock(); IUnknown** pp = m_vec.begin(); while (pp < m_vec.end()) { if (*pp != NULL) { pvars[3].vt = VT_I2; pvars[3].iVal= Button; pvars[2].vt = VT_I2; pvars[2].iVal= Shift; pvars[1].vt = VT_I4; pvars[1].lVal= x; pvars[0].vt = VT_I4; pvars[0].lVal= y; DISPPARAMS disp = { pvars, NULL, 4, 0 }; IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp); pDispatch->Invoke(DISPID_MOUSEDOWN, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); } pp++; } pT->Unlock(); delete[] pvars; } void OnMouseMove( short Button, short Shift, long x, long y) { VARIANTARG* pvars = new VARIANTARG[4]; for (int i = 0; i < 4; i++) VariantInit(&pvars[i]); T* pT = (T*)this; pT->Lock(); IUnknown** pp = m_vec.begin(); while (pp < m_vec.end()) { if (*pp != NULL) { pvars[3].vt = VT_I2; pvars[3].iVal= Button; pvars[2].vt = VT_I2; pvars[2].iVal= Shift; pvars[1].vt = VT_I4; pvars[1].lVal= x; pvars[0].vt = VT_I4; pvars[0].lVal= y; DISPPARAMS disp = { pvars, NULL, 4, 0 }; IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp); pDispatch->Invoke(DISPID_MOUSEMOVE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); } pp++; } pT->Unlock(); delete[] pvars; } void OnMouseUp( short Button, short Shift, long x, long y) { VARIANTARG* pvars = new VARIANTARG[4]; for (int i = 0; i < 4; i++) VariantInit(&pvars[i]); T* pT = (T*)this; pT->Lock(); IUnknown** pp = m_vec.begin(); while (pp < m_vec.end()) { if (*pp != NULL) { pvars[3].vt = VT_I2; pvars[3].iVal= Button; pvars[2].vt = VT_I2; pvars[2].iVal= Shift; pvars[1].vt = VT_I4; pvars[1].lVal= x; pvars[0].vt = VT_I4; pvars[0].lVal= y; DISPPARAMS disp = { pvars, NULL, 4, 0 }; IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp); pDispatch->Invoke(DISPID_MOUSEUP, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); } pp++; } pT->Unlock(); delete[] pvars; } };