Leaked source code of windows server 2003
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.

111 lines
4.4 KiB

  1. #ifndef _DROPTGT_H_
  2. #define _DROPTGT_H_
  3. // There are two drag-drop support objects:
  4. //
  5. // CDropTargetWrap - This object takes a collection of drop-target
  6. // objects and wraps them as one drop-target
  7. // handler. The first drop-target wins over the
  8. // the last one if there is a conflict in who
  9. // will take the drop.
  10. //
  11. // CDelegateDropTarget - This class implements IDropTarget given an
  12. // IDelegateDropTargetCB interface. It handles
  13. // all hit testing, caching, and scrolling for you.
  14. // Use this class by inheriting it in your derived
  15. // class; it is not intended to be instantiated alone.
  16. //
  17. // Event notifications for HitTestDDT
  18. #define HTDDT_ENTER 0
  19. #define HTDDT_OVER 1
  20. #define HTDDT_LEAVE 2
  21. class CDelegateDropTarget : public IDropTarget
  22. {
  23. public:
  24. // *** IDropTarget methods ***
  25. virtual STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  26. virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  27. virtual STDMETHODIMP DragLeave(void);
  28. virtual STDMETHODIMP Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  29. // *** Other methods to be implemented by derived class ***
  30. virtual HRESULT GetWindowsDDT (HWND * phwndLock, HWND * phwndScroll) PURE;
  31. virtual HRESULT HitTestDDT (UINT nEvent, LPPOINT ppt, DWORD_PTR * pdwId, DWORD *pdwEffect) PURE;
  32. virtual HRESULT GetObjectDDT (DWORD_PTR dwId, REFIID riid, LPVOID * ppvObj) PURE;
  33. virtual HRESULT OnDropDDT (IDropTarget *pdt, IDataObject *pdtobj,
  34. DWORD * pgrfKeyState, POINTL pt, DWORD *pdwEffect) PURE;
  35. friend IDropTarget* DropTargetWrap_CreateInstance(IDropTarget* pdtPrimary,
  36. IDropTarget* pdtSecondary,
  37. HWND hwnd, IDropTarget* pdt3 = NULL);
  38. protected:
  39. CDelegateDropTarget();
  40. virtual ~CDelegateDropTarget();
  41. BOOL IsValid() { return (_hwndLock && _hwndScroll); }
  42. void SetCallback(IDelegateDropTargetCB* pdtcb);
  43. HRESULT Init(); // init lock + scroll windows
  44. friend IDropTarget* DelegateDropTarget_CreateInstance(IDelegateDropTargetCB* pdtcb);
  45. private:
  46. void _ReleaseCurrentDropTarget();
  47. // the below are parameters we use to implement this IDropTarget
  48. HWND _hwndLock;
  49. HWND _hwndScroll;
  50. // the object we are dragging
  51. LPDATAOBJECT _pDataObj; // from DragEnter()/Drop()
  52. // the below indicate the current drag state
  53. BITBOOL _fPrime:1; // TRUE iff _itemOver/_grfKeyState is valid
  54. DWORD_PTR _itemOver; // item we are visually dragging over
  55. IDropTarget* _pdtCur; // drop target for _itemOver
  56. DWORD _grfKeyState; // cached key state
  57. DWORD _dwEffectOut; // last *pdwEffect out
  58. POINT _ptLast; // last dragged position
  59. // for scrolling
  60. RECT _rcLockWindow; // WindowRect of hwnd for DAD_ENTER
  61. AUTO_SCROLL_DATA _asd; // for auto scrolling
  62. } ;
  63. // dummy drop target to only call DAD_DragEnterEx() on DragEnter();
  64. class CDropDummy : public IDropTarget
  65. {
  66. public:
  67. // *** IUnknown ***
  68. virtual STDMETHODIMP_(ULONG) AddRef(void);
  69. virtual STDMETHODIMP_(ULONG) Release(void);
  70. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  71. // *** IDropTarget methods ***
  72. virtual STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  73. virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  74. virtual STDMETHODIMP DragLeave(void)
  75. {
  76. DAD_DragLeave();
  77. return(S_OK);
  78. };
  79. virtual STDMETHODIMP Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
  80. {
  81. DragLeave();
  82. return(S_OK);
  83. };
  84. CDropDummy(HWND hwndLock) : _hwndLock(hwndLock), _cRef(1) { return; };
  85. protected:
  86. ~CDropDummy() { return; };
  87. private:
  88. HWND _hwndLock; // window for dummy drop target.
  89. int _cRef;
  90. };
  91. #endif // _DROPTGT_H_