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

  1. // Outer.h : Declaration of the COuter
  2. //
  3. // This is a part of the ActiveX Template Library.
  4. // Copyright (C) 1996 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // ActiveX Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // ActiveX Template Library product.
  12. //
  13. #ifndef _OUTER_H
  14. #define _OUTER_H
  15.  
  16. #include "mapres.h"       // main symbols
  17. #include "chain.h"
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // COMMap
  21.  
  22. class COuter;
  23.  
  24. class CTearOff1:
  25.     public CComDualImpl<ITearOff1, &__uuidof(ITearOff1), &LIBID_COMMAPLib>,
  26.     public CComTearOffObjectBase<COuter>
  27. {
  28. public:
  29.     CTearOff1(){}
  30.     ~CTearOff1(){}
  31.  
  32.     BEGIN_COM_MAP(CTearOff1)
  33.         COM_INTERFACE_ENTRY(ITearOff1)
  34.     END_COM_MAP()
  35.  
  36.     HRESULT STDMETHODCALLTYPE get_Name(BSTR* pbstrName)
  37.     {
  38.         *pbstrName = ::SysAllocString(L"ITearOff1");
  39.         return S_OK;
  40.     }
  41. };
  42.  
  43. class CTearOff2:
  44.     public CComDualImpl<ITearOff2, &__uuidof(ITearOff2), &LIBID_COMMAPLib>,
  45.     public CComTearOffObjectBase<COuter>
  46. {
  47. public:
  48.     CTearOff2(){}
  49.     ~CTearOff2(){}
  50.  
  51.     BEGIN_COM_MAP(CTearOff2)
  52.         COM_INTERFACE_ENTRY(ITearOff2)
  53.     END_COM_MAP()
  54.  
  55.     HRESULT STDMETHODCALLTYPE get_Name(BSTR* pbstrName)
  56.     {
  57.         *pbstrName = ::SysAllocString(L"ITearOff2");
  58.         return S_OK;
  59.     }
  60. };
  61.  
  62. class COuter : 
  63.     public CChainBase,
  64.     public CComDualImpl<IOuter, &__uuidof(IOuter), &LIBID_COMMAPLib>, 
  65.     public CComCoClass<COuter,&__uuidof(CoOuter)>
  66. {
  67. public:
  68.     COuter(){}
  69.     ~COuter(){}
  70.     HRESULT FinalConstruct();
  71.     void FinalRelease();
  72. BEGIN_COM_MAP(COuter)
  73.     COM_INTERFACE_ENTRY2(IDispatch, IOuter)
  74.     COM_INTERFACE_ENTRY(IOuter)
  75.     COM_INTERFACE_ENTRY_TEAR_OFF(__uuidof(ITearOff1), CTearOff1)
  76.     COM_INTERFACE_ENTRY_CACHED_TEAR_OFF(__uuidof(ITearOff2), CTearOff2, m_pUnkTearOff2.p)
  77.     COM_INTERFACE_ENTRY_AGGREGATE(__uuidof(IAgg), m_pUnkAgg.p)
  78.     COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pUnkAggBlind.p)
  79.     COM_INTERFACE_ENTRY_AUTOAGGREGATE(__uuidof(IAutoAgg), m_pUnkAutoAgg.p, __uuidof(CoAutoAgg))
  80.     COM_INTERFACE_ENTRY_AUTOAGGREGATE_BLIND(m_pUnkAutoAggB.p, __uuidof(CoAutoAggB))
  81.     COM_INTERFACE_ENTRY(ISupportErrorInfo)
  82.     COM_INTERFACE_ENTRY_CHAIN(CChainBase)
  83. END_COM_MAP()
  84. //DECLARE_NOT_AGGREGATABLE(COuter) 
  85. // Remove the comment from the line above if you don't want your object to 
  86. // support aggregation.  The default is to support it
  87.  
  88. DECLARE_REGISTRY_RESOURCEID(IDR_Outer)
  89. DECLARE_GET_CONTROLLING_UNKNOWN()
  90. // ISupportsErrorInfo
  91.     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  92.  
  93.     CComPtr<IUnknown> m_pUnkTearOff2;
  94.     CComPtr<IUnknown> m_pUnkAgg;
  95.     CComPtr<IUnknown> m_pUnkAggBlind;
  96.     CComPtr<IUnknown> m_pUnkAutoAgg;
  97.     CComPtr<IUnknown> m_pUnkAutoAggB;
  98.     CComObjectThreadModel::AutoCriticalSection m_sec;
  99.  
  100. // IOuter
  101. public:
  102.     STDMETHOD(GetName)(short n, BSTR* pbstrName);
  103. };
  104.  
  105. #endif // _OUTER_H
  106.