aduiDropTarget.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Purpose:
  12. //
  13. // Derives from COleDropTarget to implement drop target
  14. // The palette set and palette creates this object as a member and calls
  15. // Register() to register itself as target window for drag and drop.
  16. // Routes the drag messages to the registered window to let it handle the
  17. // drag messages.
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20. #ifndef _ADUI_DROP_TARGET_H_
  21. #define _ADUI_DROP_TARGET_H_
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif // _MSC_VER > 1000
  25. // These messages are for ***INTERNAL USE ONLY***
  26. //Drag and drop messages to send to the target window
  27. //
  28. #define UM_ADUI_DRAGENTER (WM_USER + 120)
  29. #define UM_ADUI_DRAGOVER (WM_USER + 121)
  30. #define UM_ADUI_DRAGLEAVE (WM_USER + 122)
  31. #define UM_ADUI_DROP (WM_USER + 123)
  32. #define UM_ADUI_DROPEX (WM_USER + 124)
  33. #define UM_ADUI_DRAGSCROLL (WM_USER + 125)
  34. #ifndef _ADESK_MAC_
  35. //Structure to hold the drag and drop data to be sent to the target window
  36. //while sending drag and drop messages
  37. //
  38. typedef struct tagADUI_DRAGDATA
  39. {
  40. // Pointer to the window the cursor is entering/leaving or currently over.
  41. CWnd * mpWnd;
  42. // Data object. Valid for UM_ADUI_DRAGENTER, UM_ADUI_DRAGOVER,
  43. // UM_ADUI_DROP and UM_ADUI_DROPEX.
  44. COleDataObject * mpDataObject;
  45. // State of the modifier keys. This is a combination of any number of
  46. // the following: MK_CONTROL, MK_SHIFT, MK_ALT, MK_LBUTTON, MK_MBUTTON,
  47. // and MK_RBUTTON. Valid for UM_ADUI_DRAGENTER, UM_ADUI_DRAGOVER.
  48. DWORD mdwKeyState;
  49. // Current location of cursor in client co-ordinates. Valid for
  50. // UM_ADUI_DRAGENTER, UM_ADUI_DRAGOVER, UM_ADUI_DROP and
  51. // UM_ADUI_DROPEX
  52. POINTL mPoint;
  53. // The drop effect that the user chose for the default drop operation
  54. // based on the current key state. Valid for UM_ADUI_DROP and
  55. // UM_ADUI_DROPEX.
  56. DROPEFFECT mDropEffect;
  57. // List of the drop effects that the drop source supports. Valid for
  58. // UM_ADUI_DROPEX
  59. DROPEFFECT mDropList;
  60. } ADUI_DRAGDATA,*PADUI_DRAGDATA;
  61. // This class is for ***INTERNAL USE ONLY***
  62. // CAdUiDropTarget class is used to make a window a drag and drop target.
  63. // Declare a member variable of this class in the CWnd derived class which
  64. // is to be made drop target and call CAdUiDropTarget::Register() to
  65. // register the window as drop target. The drag and drop messages received
  66. // by this object is routed back to the respective window which contains
  67. // this object as UM_ADUI_xxx messages. The drag and drop messages are
  68. // UM_ADUI_DRAGENTER, UM_ADUI_DRAGOVER, UM_ADUI_DRAGLEAVE, UM_ADUI_DROP,
  69. // UM_ADUI_DROPEX, UM_ADUI_DRAGSCROLL. All the messages except UM_ADUI_DRAGLEAVE
  70. // contain ADUI_DRAGDATA structure pointer as lParam.
  71. // Handle these messages in the window class and return appropriate return value.
  72. //
  73. #pragma warning(push)
  74. #pragma warning(disable : 4275)
  75. class CAdUiDropTarget : public COleDropTarget
  76. {
  77. public:
  78. CAdUiDropTarget();
  79. // For internal use only
  80. CAdUiDropTarget(int nId);
  81. ~CAdUiDropTarget();
  82. // For internal use only
  83. BOOL SetTargetWindowForMessages(CWnd* pWnd);
  84. protected:
  85. virtual DROPEFFECT OnDragEnter (CWnd* pWnd,
  86. COleDataObject* pDataObject,
  87. DWORD dwKeyState,
  88. CPoint point);
  89. virtual DROPEFFECT OnDragOver (CWnd* pWnd,
  90. COleDataObject* pDataObject,
  91. DWORD dwKeyState,
  92. CPoint point);
  93. virtual BOOL OnDrop (CWnd* pWnd,
  94. COleDataObject* pDataObject,
  95. DROPEFFECT dropEffect,
  96. CPoint point);
  97. virtual DROPEFFECT OnDropEx (CWnd* pWnd,
  98. COleDataObject* pDataObject,
  99. DROPEFFECT dropDefault,
  100. DROPEFFECT dropList,
  101. CPoint point);
  102. virtual void OnDragLeave (CWnd* pWnd);
  103. virtual DROPEFFECT OnDragScroll (CWnd* pWnd,
  104. DWORD dwKeyState,
  105. CPoint point);
  106. protected:
  107. DWORD mdwKeyState;
  108. int mnId;
  109. CWnd * mpTargetWnd;
  110. };
  111. #pragma warning(pop)
  112. #endif // _ADESK_MAC_
  113. #endif // _ADUI_DROP_TARGET_H_