home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / cmdwnd / msdevcmd / devcmdcp.h < prev    next >
C/C++ Source or Header  |  1998-04-02  |  944b  |  34 lines

  1. #ifndef _DEVCMDCP_H_
  2. #define _DEVCMDCP_H_
  3. #include "devcmd.h"
  4.  
  5. template <class T>
  6. class CProxy_ICommandWindowEvents : public IConnectionPointImpl<T, &DIID__ICommandWindowEvents, CComDynamicUnkArray>
  7. {
  8.     //Warning this class may be recreated by the wizard.
  9. public:
  10.     HRESULT Fire_OnClose()
  11.     {
  12.         CComVariant varResult;
  13.         T* pT = static_cast<T*>(this);
  14.         int nConnectionIndex;
  15.         int nConnections = m_vec.GetSize();
  16.         
  17.         for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  18.         {
  19.             pT->Lock();
  20.             CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  21.             pT->Unlock();
  22.             IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  23.             if (pDispatch != NULL)
  24.             {
  25.                 VariantClear(&varResult);
  26.                 DISPPARAMS disp = { NULL, NULL, 0, 0 };
  27.                 pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
  28.             }
  29.         }
  30.         return varResult.scode;
  31.     
  32.     }
  33. };
  34. #endif