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.

74 lines
2.9 KiB

  1. #pragma once
  2. #ifndef DD_H_INCLUDED
  3. #define DD_H_INCLUDED
  4. /*
  5. Classes participating in Drag-And-Drop:
  6. CMMCDropSource
  7. 1. Implements IDropSource interface and the created instance of this class
  8. is given to OLE for d&d operation
  9. 2. Implements static member ScDoDragDrop which creates the instance and starts d&d
  10. by calling OLE Api function
  11. CMMCDropTarget ( TiedComObject tied to CMMCViewDropTarget )
  12. Implements interface IDropTarget interface and the created instance of this class
  13. is given to OLE for d&d operation. Its instances are tied to CMMCViewDropTarget instance
  14. and it places the call to this class in respond to method invocations made by OLE
  15. CMMCViewDropTarget
  16. Adds d&d support to the view by creating the instance of CMMCDropTarget (TiedComObject)
  17. and registering it with OLE, responding to method calls made by that instance and invoking
  18. virtual methods on derived class to do the HitTest/Drop.
  19. Registration in done by invoking protected method ScRegisterAsDropTarget.
  20. Target is revoke on destructor.
  21. CAMCTreeView
  22. Derives from CMMCViewDropTarget. Registers after window is created.
  23. Implements virtual methods to HitTest / Perform the Drop.
  24. CAMCListView
  25. Derives from CMMCViewDropTarget. Registers after window is created.
  26. Implements virtual methods to HitTest / Perform the Drop.
  27. */
  28. /***************************************************************************\
  29. *
  30. * CLASS: CMMCViewDropTarget
  31. *
  32. * PURPOSE: Defines common behavior for D&D-enabled view,
  33. * Also defines the interface for HitTest function
  34. *
  35. * USAGE: Derive your view from this class (CAMCListView and CAMCTreeView does)
  36. * Implement virtual methods ScDropOnTarget and RemoveDropTargetHiliting in your class
  37. * Add a call to ScRegisterAsDropTarget() after the window is created
  38. *
  39. \***************************************************************************/
  40. class CMMCViewDropTarget : public CTiedObject
  41. {
  42. protected:
  43. // these methods should only be used by the derived class
  44. // construction - destruction
  45. CMMCViewDropTarget();
  46. ~CMMCViewDropTarget();
  47. // drop target registration
  48. SC ScRegisterAsDropTarget(HWND hWnd);
  49. public:
  50. // interface methods the derived class must implement
  51. virtual SC ScDropOnTarget(bool bHitTestOnly, IDataObject * pDataObject, CPoint pt, bool& bCopyOperation) = 0;
  52. virtual void RemoveDropTargetHiliting() = 0;
  53. // accessory used by tied com object to display the context menu
  54. HWND GetWindowHandle() { return m_hwndOwner; }
  55. private:
  56. // implementation helper - creates tied com object
  57. SC ScCreateTarget(IDropTarget **ppTarget);
  58. IDropTargetPtr m_spTarget; // tied com object
  59. HWND m_hwndOwner; // window handle of the wiew
  60. };
  61. #endif DD_H_INCLUDED