home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / dcom / drawserv / cpidserv.h next >
C/C++ Source or Header  |  1998-04-02  |  996b  |  38 lines

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. // IDrawServ : IDispatch (Dual)
  3.  
  4. template <class T>
  5. class CProxyIDrawServ :
  6.     public IConnectionPointImpl<T, &IID_IDrawServ, CComDynamicUnkArray>
  7. {
  8. public:
  9. //  CProxyIDrawServ(IConnectionPointContainer* pCont) :
  10. //      CComConnectionPoint< CComDynamicArrayCONNECTDATA >(pCont, &IID_IDrawServ)
  11. //  {
  12. //  }
  13.  
  14. public:
  15.     HRESULT Draw(
  16.         long x1, long y1,
  17.         long x2, long y2,
  18.         unsigned long col)
  19.     {
  20.         T* pT = (T*)this;
  21.         pT->Lock();
  22.         HRESULT hr = S_OK;
  23.         IUnknown** pp = m_vec.begin();
  24.         IUnknown** ppEnd = m_vec.end();
  25.         while (pp < ppEnd && hr == S_OK)
  26.         {
  27.             if (*pp != NULL)
  28.             {
  29.                 IDrawServ* pIDrawServ = (IDrawServ*)*pp;
  30.                 hr = pIDrawServ->Draw(x1, y1, x2, y2, col);
  31.             }
  32.             pp++;
  33.         }
  34.         pT->Unlock();
  35.         return hr;
  36.     }
  37. };
  38.