home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / common / msdev98 / template / atl / proppage.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  3KB  |  124 lines

  1. [!if=(FreeThreadedMarshaler, "TRUE")]
  2.     [!set(NeedsGetControllingUnknown, "TRUE")]
  3. [!endif]
  4. // [!HeaderName] : Declaration of the [!ClassName]
  5. [!crlf]
  6.  
  7. [!if=(FileExists, "FALSE")]
  8. #ifndef __[!UpperShortName]_H_
  9. #define __[!UpperShortName]_H_
  10. [!crlf]
  11. #include "resource.h"       // main symbols
  12. [!else]
  13. [!AddIncludeFile(TargetFile, "resource.h")]
  14. [!endif]
  15.  
  16. [!crlf]
  17. EXTERN_C const CLSID CLSID_[!CoClassName];
  18. [!crlf]
  19. /////////////////////////////////////////////////////////////////////////////
  20. // [!ClassName]
  21.  
  22. class ATL_NO_VTABLE [!ClassName] :
  23. [!if=(ThreadingModel, "Single")]
  24.     public CComObjectRootEx<CComSingleThreadModel>,
  25. [!endif]
  26. [!if=(ThreadingModel, "Apartment")]
  27.     public CComObjectRootEx<CComSingleThreadModel>,
  28. [!endif]
  29. [!if=(ThreadingModel, "Both")]
  30.     public CComObjectRootEx<CComMultiThreadModel>,
  31. [!endif]
  32. [!if=(ThreadingModel, "Free")]
  33.     public CComObjectRootEx<CComMultiThreadModel>,
  34. [!endif]
  35.     public CComCoClass<[!ClassName], &CLSID_[!CoClassName]>,
  36.     public IPropertyPageImpl<[!ClassName]>,
  37.     public CDialogImpl<[!ClassName]>
  38. {
  39. public:
  40.     [!ClassName]() 
  41.     {
  42. [!if=(FreeThreadedMarshaler, "TRUE")]
  43.         m_pUnkMarshaler = NULL;
  44. [!endif]
  45.         m_dwTitleID = [!IDS_TITLE];
  46.         m_dwHelpFileID = [!IDS_HELPFILE];
  47.         m_dwDocStringID = [!IDS_DOCSTRING];
  48.     }
  49.  
  50. [!crlf]
  51.     enum {IDD = IDD_[!UpperShortName]};
  52.  
  53. [!crlf]
  54. [!if=(NeedsGetControllingUnknown, "TRUE")]
  55. DECLARE_GET_CONTROLLING_UNKNOWN()
  56. [!endif]
  57. DECLARE_REGISTRY_RESOURCEID([!IDR_REGISTRYID])
  58.  
  59. [!if=(Aggregatable, "NO")]
  60. DECLARE_NOT_AGGREGATABLE([!ClassName])
  61. [!endif]
  62. [!if=(Aggregatable, "ONLY")]
  63. DECLARE_ONLY_AGGREGATABLE([!ClassName])
  64. [!endif]
  65. [!crlf]
  66. DECLARE_PROTECT_FINAL_CONSTRUCT()
  67.  
  68. [!crlf]
  69. BEGIN_COM_MAP([!ClassName]) 
  70.     COM_INTERFACE_ENTRY(IPropertyPage)
  71. [!if=(FreeThreadedMarshaler, "TRUE")]
  72.     COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  73. [!endif]
  74. END_COM_MAP()
  75.  
  76. [!crlf]
  77. BEGIN_MSG_MAP([!ClassName])
  78.     CHAIN_MSG_MAP(IPropertyPageImpl<[!ClassName]>)
  79. END_MSG_MAP()
  80. // Handler prototypes:
  81. //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  82. //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  83. //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  84.  
  85. [!if=(FreeThreadedMarshaler, "TRUE")]
  86. [!crlf]
  87.     HRESULT FinalConstruct()
  88.     {
  89.         return CoCreateFreeThreadedMarshaler(
  90.             GetControllingUnknown(), &m_pUnkMarshaler.p);
  91.     }
  92.  
  93. [!crlf]
  94.     void FinalRelease()
  95.     {
  96.         m_pUnkMarshaler.Release();
  97.     }
  98.  
  99. [!crlf]
  100.     CComPtr<IUnknown> m_pUnkMarshaler;
  101. [!endif]
  102.  
  103. [!crlf]
  104.     STDMETHOD(Apply)(void)
  105.     {
  106.         ATLTRACE(_T("[!ClassName]::Apply\n"));
  107.         for (UINT i = 0; i < m_nObjects; i++)
  108.         {
  109.             // Do something interesting here
  110.             // ICircCtl* pCirc;
  111.             // m_ppUnk[i]->QueryInterface(IID_ICircCtl, (void**)&pCirc);
  112.             // pCirc->put_Caption(CComBSTR("something special"));
  113.             // pCirc->Release();
  114.         }
  115.         m_bDirty = FALSE;
  116.         return S_OK;
  117.     }
  118. };
  119.  
  120. [!crlf]
  121. [!if=(FileExists, "FALSE")]
  122. #endif //__[!UpperShortName]_H_
  123. [!endif]
  124.