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

  1. // Outer.h : Declaration of the COuter
  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 _OUTER_H
  14. #define _OUTER_H
  15.  
  16. #include "mapres.h"       // main symbols
  17. #include "chain.h"
  18. #include "aggreg\aggreg.h"
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // COMMap
  22.  
  23. class COuter;
  24.  
  25. class CTearOff1:
  26.     public IDispatchImpl<ITearOff1, &IID_ITearOff1, &LIBID_COMMAPLib>,
  27.     public CComTearOffObjectBase<COuter>
  28. {
  29. public:
  30.     CTearOff1(){}
  31.     ~CTearOff1(){}
  32.  
  33.     BEGIN_COM_MAP(CTearOff1)
  34.         COM_INTERFACE_ENTRY(ITearOff1)
  35.     END_COM_MAP()
  36.  
  37.     HRESULT STDMETHODCALLTYPE get_Name(BSTR* pbstrName)
  38.     {
  39.         *pbstrName = ::SysAllocString(L"ITearOff1");
  40.         return S_OK;
  41.     }
  42. };
  43.  
  44. class CTearOff2:
  45.     public IDispatchImpl<ITearOff2, &IID_ITearOff2, &LIBID_COMMAPLib>,
  46.     public CComTearOffObjectBase<COuter>
  47. {
  48. public:
  49.     CTearOff2(){}
  50.     ~CTearOff2(){}
  51.  
  52.     BEGIN_COM_MAP(CTearOff2)
  53.         COM_INTERFACE_ENTRY(ITearOff2)
  54.     END_COM_MAP()
  55.  
  56.     HRESULT STDMETHODCALLTYPE get_Name(BSTR* pbstrName)
  57.     {
  58.         *pbstrName = ::SysAllocString(L"ITearOff2");
  59.         return S_OK;
  60.     }
  61. };
  62.  
  63. class COuter :
  64.     public CChainBase,
  65.     public IDispatchImpl<IOuter, &IID_IOuter, &LIBID_COMMAPLib>,
  66.     public CComCoClass<COuter,&CLSID_COuter>
  67. {
  68. public:
  69.     COuter(){}
  70.     ~COuter(){}
  71.     HRESULT FinalConstruct();
  72.     void FinalRelease();
  73. BEGIN_COM_MAP(COuter)
  74.     COM_INTERFACE_ENTRY2(IDispatch, IOuter)
  75.     COM_INTERFACE_ENTRY(IOuter)
  76.     COM_INTERFACE_ENTRY_TEAR_OFF(IID_ITearOff1, CTearOff1)
  77.     COM_INTERFACE_ENTRY_CACHED_TEAR_OFF(IID_ITearOff2, CTearOff2, m_pUnkTearOff2.p)
  78.     COM_INTERFACE_ENTRY_AGGREGATE(IID_IAgg, m_pUnkAgg.p)
  79.     COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pUnkAggBlind.p)
  80.     COM_INTERFACE_ENTRY_AUTOAGGREGATE(IID_IAutoAgg, m_pUnkAutoAgg.p, CLSID_CAutoAgg)
  81.     COM_INTERFACE_ENTRY_AUTOAGGREGATE_BLIND(m_pUnkAutoAggB.p, CLSID_CAutoAggB)
  82.     COM_INTERFACE_ENTRY(ISupportErrorInfo)
  83.     COM_INTERFACE_ENTRY_CHAIN(CChainBase)
  84. END_COM_MAP()
  85. //DECLARE_NOT_AGGREGATABLE(COuter)
  86. // Remove the comment from the line above if you don't want your object to
  87. // support aggregation.  The default is to support it
  88.  
  89. DECLARE_REGISTRY_RESOURCEID(IDR_Outer)
  90. DECLARE_GET_CONTROLLING_UNKNOWN()
  91. // ISupportsErrorInfo
  92.     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  93.  
  94.     CComPtr<IUnknown> m_pUnkTearOff2;
  95.     CComPtr<IUnknown> m_pUnkAgg;
  96.     CComPtr<IUnknown> m_pUnkAggBlind;
  97.     CComPtr<IUnknown> m_pUnkAutoAgg;
  98.     CComPtr<IUnknown> m_pUnkAutoAggB;
  99.     CComObjectThreadModel::AutoCriticalSection m_sec;
  100.  
  101. // IOuter
  102. public:
  103.     STDMETHOD(GetName)(short n, BSTR* pbstrName);
  104. };
  105.  
  106. #endif // _OUTER_H
  107.