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.

131 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dataobj.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _DATAOBJ_H
  11. #define _DATAOBJ_H
  12. class CDataObject : public IDataObject, public CComObjectRoot
  13. {
  14. public:
  15. // ATL Maps
  16. DECLARE_NOT_AGGREGATABLE(CDataObject)
  17. BEGIN_COM_MAP(CDataObject)
  18. COM_INTERFACE_ENTRY(IDataObject)
  19. END_COM_MAP()
  20. // Construction/Destruction
  21. CDataObject() : m_lNotifyHandle(0), m_hwndParentSheet(NULL)
  22. {
  23. m_pComponentData = NULL;
  24. };
  25. ~CDataObject()
  26. {
  27. if (m_pComponentData != NULL)
  28. {
  29. m_pComponentData->Release();
  30. m_pComponentData = NULL;
  31. }
  32. };
  33. void SetIComponentData(CComponentDataImpl* pData)
  34. {
  35. ASSERT(pData);
  36. ASSERT(m_pComponentData == NULL);
  37. LPUNKNOWN pUnk = pData->GetUnknown();
  38. HRESULT hr;
  39. hr = pUnk->QueryInterface(IID_IComponentData, reinterpret_cast<void**>(&m_pComponentData));
  40. ASSERT(hr == S_OK);
  41. }
  42. public:
  43. // Clipboard formats that are required by the console
  44. static CLIPFORMAT m_cfNodeType;
  45. static CLIPFORMAT m_cfNodeTypeString;
  46. static CLIPFORMAT m_cfDisplayName;
  47. static CLIPFORMAT m_cfCoClass;
  48. // internal clipboard format
  49. static CLIPFORMAT m_cfInternal;
  50. // Property Page Clipboard formats
  51. static CLIPFORMAT m_cfDsObjectNames;
  52. static CLIPFORMAT m_cfDsDisplayOptions;
  53. static CLIPFORMAT m_cfGetIPropSheetCfg;
  54. // Standard IDataObject methods
  55. public:
  56. // Implemented
  57. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium);
  58. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  59. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
  60. ULONG InternalAddRef()
  61. {
  62. return CComObjectRoot::InternalAddRef();
  63. }
  64. ULONG InternalRelease()
  65. {
  66. return CComObjectRoot::InternalRelease();
  67. }
  68. // Not Implemented
  69. private:
  70. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  71. { return E_NOTIMPL; };
  72. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  73. { return E_NOTIMPL; };
  74. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease);
  75. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  76. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  77. { return E_NOTIMPL; };
  78. STDMETHOD(DUnadvise)(DWORD dwConnection)
  79. { return E_NOTIMPL; };
  80. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  81. { return E_NOTIMPL; };
  82. // Implementation
  83. public:
  84. void SetType(DATA_OBJECT_TYPES type)
  85. { ASSERT(m_internal.m_type == CCT_UNINITIALIZED); m_internal.m_type = type; }
  86. void SetCookie(MMC_COOKIE cookie) { m_internal.m_cookie = cookie; }
  87. void SetString(LPCTSTR lpString) { m_internal.m_string = lpString; }
  88. void SetClass(LPCTSTR lpString) { m_internal.m_class = lpString; }
  89. private:
  90. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  91. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  92. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  93. HRESULT CreateInternal(LPSTGMEDIUM lpMedium);
  94. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  95. HRESULT Create(const void* pBuffer, int len, LPSTGMEDIUM lpMedium);
  96. INTERNAL m_internal;
  97. LPCOMPONENTDATA m_pComponentData; // pointer to the IComponetData object
  98. LONG_PTR m_lNotifyHandle;
  99. HWND m_hwndParentSheet;
  100. };
  101. #endif // _DATAOBJ_H