Back to index

plt-scheme  4.2.1
testobjectCP.h
Go to the documentation of this file.
00001 #ifndef _TESTOBJECTCP_H_
00002 #define _TESTOBJECTCP_H_
00003 
00004 
00005 
00006 
00007 
00008 
00009 template <class T>
00010 class CProxy_ITestControlEvents : public IConnectionPointImpl<T, &DIID__ITestControlEvents, CComDynamicUnkArray>
00011 {
00012        //Warning this class may be recreated by the wizard.
00013 public:
00014        HRESULT Fire_Click()
00015        {
00016               CComVariant varResult;
00017               T* pT = static_cast<T*>(this);
00018               int nConnectionIndex;
00019               int nConnections = m_vec.GetSize();
00020               
00021               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00022               {
00023                      pT->Lock();
00024                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00025                      pT->Unlock();
00026                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00027                      if (pDispatch != NULL)
00028                      {
00029                             VariantClear(&varResult);
00030                             DISPPARAMS disp = { NULL, NULL, 0, 0 };
00031                             pDispatch->Invoke(DISPID_CLICK, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00032                      }
00033               }
00034               return varResult.scode;
00035        
00036        }
00037        HRESULT Fire_MouseDown(SHORT button, SHORT shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
00038        {
00039               CComVariant varResult;
00040               T* pT = static_cast<T*>(this);
00041               int nConnectionIndex;
00042               CComVariant* pvars = new CComVariant[4];
00043               int nConnections = m_vec.GetSize();
00044               
00045               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00046               {
00047                      pT->Lock();
00048                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00049                      pT->Unlock();
00050                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00051                      if (pDispatch != NULL)
00052                      {
00053                             VariantClear(&varResult);
00054                             pvars[3] = button;
00055                             pvars[2] = shift;
00056                             pvars[1] = x;
00057                             pvars[0] = y;
00058                             DISPPARAMS disp = { pvars, NULL, 4, 0 };
00059                             pDispatch->Invoke(DISPID_MOUSEDOWN, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00060                      }
00061               }
00062               delete[] pvars;
00063               return varResult.scode;
00064        
00065        }
00066        HRESULT Fire_MouseUp(SHORT button, SHORT shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
00067        {
00068               CComVariant varResult;
00069               T* pT = static_cast<T*>(this);
00070               int nConnectionIndex;
00071               CComVariant* pvars = new CComVariant[4];
00072               int nConnections = m_vec.GetSize();
00073               
00074               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00075               {
00076                      pT->Lock();
00077                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00078                      pT->Unlock();
00079                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00080                      if (pDispatch != NULL)
00081                      {
00082                             VariantClear(&varResult);
00083                             pvars[3] = button;
00084                             pvars[2] = shift;
00085                             pvars[1] = x;
00086                             pvars[0] = y;
00087                             DISPPARAMS disp = { pvars, NULL, 4, 0 };
00088                             pDispatch->Invoke(DISPID_MOUSEUP, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00089                      }
00090               }
00091               delete[] pvars;
00092               return varResult.scode;
00093        
00094        }
00095        HRESULT Fire_KeyDown(SHORT * keyCode, SHORT shift)
00096        {
00097               CComVariant varResult;
00098               T* pT = static_cast<T*>(this);
00099               int nConnectionIndex;
00100               CComVariant* pvars = new CComVariant[2];
00101               int nConnections = m_vec.GetSize();
00102               
00103               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00104               {
00105                      pT->Lock();
00106                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00107                      pT->Unlock();
00108                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00109                      if (pDispatch != NULL)
00110                      {
00111                             VariantClear(&varResult);
00112                             pvars[1] = keyCode;
00113                             pvars[0] = shift;
00114                             DISPPARAMS disp = { pvars, NULL, 2, 0 };
00115                             pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00116                      }
00117               }
00118               delete[] pvars;
00119               return varResult.scode;
00120        
00121        }
00122        HRESULT Fire_KeyUp(SHORT *keyCode, SHORT shift)
00123        {
00124               CComVariant varResult;
00125               T* pT = static_cast<T*>(this);
00126               int nConnectionIndex;
00127               CComVariant* pvars = new CComVariant[2];
00128               int nConnections = m_vec.GetSize();
00129               
00130               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00131               {
00132                      pT->Lock();
00133                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00134                      pT->Unlock();
00135                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00136                      if (pDispatch != NULL)
00137                      {
00138                             VariantClear(&varResult);
00139                             pvars[1] = keyCode;
00140                             pvars[0] = shift;
00141                             DISPPARAMS disp = { pvars, NULL, 2, 0 };
00142                             pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00143                      }
00144               }
00145               delete[] pvars;
00146               return varResult.scode;
00147        
00148        }
00149        HRESULT Fire_MouseMove(SHORT button, SHORT shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
00150        {
00151               CComVariant varResult;
00152               T* pT = static_cast<T*>(this);
00153               int nConnectionIndex;
00154               CComVariant* pvars = new CComVariant[4];
00155               int nConnections = m_vec.GetSize();
00156               
00157               for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
00158               {
00159                      pT->Lock();
00160                      CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
00161                      pT->Unlock();
00162                      IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
00163                      if (pDispatch != NULL)
00164                      {
00165                             VariantClear(&varResult);
00166                             pvars[3] = button;
00167                             pvars[2] = shift;
00168                             pvars[1] = x;
00169                             pvars[0] = y;
00170                             DISPPARAMS disp = { pvars, NULL, 4, 0 };
00171                             pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
00172                      }
00173               }
00174               delete[] pvars;
00175               return varResult.scode;
00176        
00177        }
00178 };
00179 #endif