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.

146 lines
2.7 KiB

  1. #include "dataobj.h"
  2. extern HINSTANCE g_hInstance;
  3. DWORD g_dwID=0;
  4. DWORD g_foobar;
  5. CDataObject::CDataObject(
  6. LPUNKNOWN pUnkOuter,
  7. PFNDESTROYED pfnDestroy
  8. )
  9. {
  10. m_cRef = 0;
  11. m_pUnkOuter = pUnkOuter;
  12. m_pfnDestroy = pfnDestroy;
  13. m_hWndAdvise = NULL;
  14. m_dwAdvFlags = ADVF_NODATA;
  15. m_pIDataObject = NULL;
  16. m_pIDataAdviseHolder = NULL;
  17. m_cfeGet = CFORMATETCGET;
  18. SETDefFormatEtc(m_rgfeGet[0], CF_TEXT, TYMED_HGLOBAL);
  19. m_dataText = NULL;
  20. m_cDataSize = DATASIZE_FROM_INDEX(1);
  21. return;
  22. }
  23. CDataObject::~CDataObject(void)
  24. {
  25. if (NULL != m_dataText)
  26. delete m_dataText;
  27. if (NULL != m_pIDataAdviseHolder)
  28. m_pIDataAdviseHolder->Release();
  29. if (NULL != m_pIDataObject)
  30. delete m_pIDataObject;
  31. if (NULL != m_hWndAdvise)
  32. DestroyWindow(m_hWndAdvise);
  33. }
  34. BOOL
  35. CDataObject::FInit(void)
  36. {
  37. LPUNKNOWN pIUnknown = (LPUNKNOWN)this;
  38. // Create the contained "IDataObject" interface and
  39. // pass it the correct containing IUnknown.
  40. if (NULL != m_pUnkOuter)
  41. pIUnknown = m_pUnkOuter;
  42. m_pIDataObject = new CImpIDataObject(this, pIUnknown);
  43. if (NULL == m_pIDataObject)
  44. return FALSE;
  45. // [ Code for "Advise Window" goes here. ]
  46. return TRUE;
  47. }
  48. STDMETHODIMP
  49. CDataObject::QueryInterface(
  50. REFIID riid,
  51. LPLPVOID ppv
  52. )
  53. {
  54. *ppv = NULL;
  55. if (IsEqualIID(riid, IID_IUnknown))
  56. *ppv = (LPVOID)this;
  57. if (IsEqualIID(riid, IID_IDataObject))
  58. *ppv = (LPVOID) m_pIDataObject;
  59. if(NULL != *ppv)
  60. {
  61. ((LPUNKNOWN)*ppv)->AddRef();
  62. return NOERROR;
  63. }
  64. return ResultFromScode(E_NOINTERFACE);
  65. }
  66. STDMETHODIMP_(ULONG)
  67. CDataObject::AddRef(void)
  68. {
  69. return ++m_cRef;
  70. }
  71. STDMETHODIMP_(ULONG)
  72. CDataObject::Release(void)
  73. {
  74. ULONG cRefT;
  75. cRefT = --m_cRef;
  76. if (0==m_cRef)
  77. {
  78. if (NULL != m_pfnDestroy)
  79. (*m_pfnDestroy)();
  80. delete this;
  81. }
  82. return cRefT;
  83. }
  84. #ifdef NOT_SIMPLE
  85. LRESULT APIENTRY
  86. AdvisorWndProc(
  87. HWND hWnd,
  88. UINT iMsg,
  89. WPARAM wParam,
  90. LPARAM lParam
  91. )
  92. {
  93. PCDataObject pDO;
  94. pDO = (PCDataObject)(GetWindowLong)(hWnd, 0);
  95. switch (iMsg)
  96. {
  97. case WM_NCCREATE:
  98. pDO = (PCDataObject) ((LONG)((LPCREATESTRUCT)lParam)
  99. ->lpCreateParams);
  100. SetWindowLong(hWnd, 0, (LONG)pDO);
  101. return (DefWindowProc(hWnd, iMsg, wParam, lParam));
  102. #ifdef FINISHED
  103. case WM_CLOSE:
  104. // Forbid the Task Manager from closing us.
  105. return 0L;
  106. #endif /* Finished */
  107. case WM_COMMAND:
  108. // [ Code for "Advise Window" goes here. ]
  109. break;
  110. default:
  111. return (DefWindowProc(hWnd, iMsg, wParam, lParam));
  112. }
  113. return 0L;
  114. }
  115. #endif /* NOT_SIMPLE */
  116.