home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / atlduck / duckdoer.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  2KB  |  86 lines

  1. // DuckDoer.h : Declaration of the CDuckDoer
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #ifndef __DUCKDOER_H_
  14. #define __DUCKDOER_H_
  15.  
  16. #include "resource.h"       // main symbols
  17. #include "cpduck.h"
  18. #include "duckdoerdlg.h"
  19. #include "atlduck.h"
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CDuckDoer
  23. class ATL_NO_VTABLE CDuckDoer :
  24.     public CComObjectRootEx<CComObjectThreadModel>,
  25.     public CComCoClass<CDuckDoer, &CLSID_DuckDoer>,
  26.     public CProxyIDuckInt<CDuckDoer>,
  27.     public IConnectionPointContainerImpl<CDuckDoer>,
  28.     public IDuckDoer
  29. {
  30. public:
  31.     CDuckDoer()
  32.     {
  33.         // The dialog has to exist always before a duck doer object is created
  34.         // because the dialog is created in tWinMain, which happens before
  35.         // IClassFactory::CreateInstance.
  36.         _ASSERT(m_pDlg != NULL);
  37.         m_pDlg->SetOwner(this);
  38.         m_bLocked = FALSE;
  39.     }
  40.  
  41.     ~CDuckDoer()
  42.     {
  43.         if (m_pDlg != NULL)
  44.         {
  45.             m_pDlg->DestroyWindow();
  46.         }
  47.     }
  48.  
  49.     HRESULT FinalConstruct()
  50.     {
  51. #ifdef _DEBUG
  52.         _ASSERTE(AddRef() > 0);
  53. #else
  54.         AddRef();
  55. #endif
  56.         return S_OK;
  57.     }
  58.  
  59. DECLARE_REGISTRY_RESOURCEID(IDR_DUCKDOER)
  60. DECLARE_NOT_AGGREGATABLE(CDuckDoer)
  61. DECLARE_CLASSFACTORY_SINGLETON(CDuckDoer)
  62.  
  63.  
  64. public:
  65.     STDMETHOD(Advise)(IUnknown* pUnk, DWORD* pdwCookie);
  66.     STDMETHOD(Unadvise)(DWORD dwCookie);
  67.  
  68.  
  69. BEGIN_COM_MAP(CDuckDoer)
  70.     COM_INTERFACE_ENTRY(IDuckDoer)
  71.     COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  72. END_COM_MAP()
  73.  
  74.     static CDuckDoerDlg* m_pDlg;
  75.     BOOL m_bLocked;
  76.  
  77. BEGIN_CONNECTION_POINT_MAP(CDuckDoer)
  78.     CONNECTION_POINT_ENTRY(IID_IDuckInt)
  79. END_CONNECTION_POINT_MAP()
  80.  
  81.     // IDuckDoer
  82. };
  83.  
  84.  
  85. #endif //__DUCKDOER_H_
  86.