Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.8 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: objfmts.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 6/12/1997 RaviR Created
  15. //____________________________________________________________________________
  16. //
  17. #ifndef _OBJFMTS_H_
  18. #define _OBJFMTS_H_
  19. HRESULT GetObjFormats(UINT cfmt, FORMATETC *afmt, LPVOID *ppvObj);
  20. HRESULT GetObjFormatsEx(IEnumFORMATETC* pEnum1, IEnumFORMATETC* pEnum2,
  21. IEnumFORMATETC** ppEnumOut);
  22. //____________________________________________________________________________
  23. //
  24. // Class: CObjFormats
  25. //
  26. // Purpose: Impements IEnumFORMATETC for objects.
  27. //____________________________________________________________________________
  28. class CObjFormats : public IEnumFORMATETC,
  29. public CComObjectRoot
  30. {
  31. public:
  32. // ATL Maps
  33. DECLARE_NOT_AGGREGATABLE(CObjFormats)
  34. BEGIN_COM_MAP(CObjFormats)
  35. COM_INTERFACE_ENTRY(IEnumFORMATETC)
  36. END_COM_MAP()
  37. public:
  38. CObjFormats() : m_iFmt(0), m_cFmt(0), m_aFmt(NULL)
  39. {
  40. }
  41. ~CObjFormats() { if (m_aFmt) delete [] m_aFmt; }
  42. void Init(UINT cfmt, FORMATETC * afmt)
  43. {
  44. m_cFmt = cfmt;
  45. m_aFmt = afmt;
  46. }
  47. // IEnumFORMATETC methods
  48. STDMETHODIMP Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed);
  49. STDMETHODIMP Skip(ULONG celt);
  50. STDMETHODIMP Reset();
  51. STDMETHODIMP Clone(IEnumFORMATETC ** ppenum);
  52. private:
  53. UINT m_iFmt;
  54. UINT m_cFmt;
  55. FORMATETC * m_aFmt;
  56. }; // class CObjFormats
  57. //____________________________________________________________________________
  58. //
  59. // Class: CObjFormatsEx
  60. //
  61. // Purpose: Impements IEnumFORMATETC for objects.
  62. //____________________________________________________________________________
  63. class CObjFormatsEx : public IEnumFORMATETC,
  64. public CComObjectRoot
  65. {
  66. public:
  67. // ATL Maps
  68. DECLARE_NOT_AGGREGATABLE(CObjFormatsEx)
  69. BEGIN_COM_MAP(CObjFormatsEx)
  70. COM_INTERFACE_ENTRY(IEnumFORMATETC)
  71. END_COM_MAP()
  72. public:
  73. CObjFormatsEx() : m_iCur(0)
  74. {
  75. }
  76. ~CObjFormatsEx()
  77. {
  78. }
  79. bool Init(IEnumFORMATETC* pEnum1, IEnumFORMATETC* pEnum2)
  80. {
  81. ASSERT(pEnum1 && pEnum2);
  82. if (!pEnum1 || !pEnum2)
  83. return false;
  84. m_rgspEnums[0] = pEnum1;
  85. m_rgspEnums[1] = pEnum2;
  86. return true;
  87. }
  88. // IEnumFORMATETC methods
  89. STDMETHODIMP Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed);
  90. STDMETHODIMP Skip(ULONG celt);
  91. STDMETHODIMP Reset();
  92. STDMETHODIMP Clone(IEnumFORMATETC ** ppenum);
  93. private:
  94. UINT m_iCur;
  95. IEnumFORMATETCPtr m_rgspEnums[2];
  96. }; // class CObjFormatsEx
  97. #endif // _OBJFMTS_H_