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.

125 lines
2.9 KiB

  1. //
  2. // Routines for implementing drop target capability to menubands.
  3. //
  4. #include "priv.h"
  5. #include "mbdrop.h"
  6. #include "iface.h" // for MBIF_
  7. #define SUPERCLASS
  8. //=================================================================
  9. // Implementation of CMenuBandDropTarget
  10. //=================================================================
  11. // Constructor
  12. CMenuBandDropTarget::CMenuBandDropTarget(HWND hwnd, int idTarget, DWORD dwFlags) :
  13. _cRef(1), _hwndParent(hwnd), _idTarget(idTarget), _dwFlagsMBIF(dwFlags)
  14. {
  15. }
  16. STDMETHODIMP_(ULONG) CMenuBandDropTarget::AddRef()
  17. {
  18. _cRef++;
  19. return _cRef;
  20. }
  21. STDMETHODIMP_(ULONG) CMenuBandDropTarget::Release()
  22. {
  23. ASSERT(_cRef > 0);
  24. _cRef--;
  25. if (_cRef > 0)
  26. return _cRef;
  27. delete this;
  28. return 0;
  29. }
  30. STDMETHODIMP CMenuBandDropTarget::QueryInterface(REFIID riid, void **ppvObj)
  31. {
  32. HRESULT hres;
  33. static const QITAB qit[] = {
  34. QITABENT(CMenuBandDropTarget, IDropTarget),
  35. { 0 },
  36. };
  37. hres = QISearch(this, (LPCQITAB)qit, riid, ppvObj);
  38. return hres;
  39. }
  40. /*----------------------------------------------------------
  41. Purpose: IDropTarget::DragEnter method
  42. */
  43. STDMETHODIMP CMenuBandDropTarget::DragEnter(IDataObject * pdtobj, DWORD grfKeyState,
  44. POINTL pt, DWORD * pdwEffect)
  45. {
  46. // If this item cascades out, then we want to pop the submenu open
  47. // after a timer. We don't allow a drop on the cascadable item
  48. // itself. (We could, but then we'd have to default to a location
  49. // inside the submenu, and I'm lazy right now.)
  50. if (*pdwEffect & (DROPEFFECT_MOVE | DROPEFFECT_COPY))
  51. {
  52. if (_dwFlagsMBIF & SMIF_SUBMENU)
  53. {
  54. // _idTimer = SetTimer(NULL, 0, 2000,
  55. }
  56. *pdwEffect &= (DROPEFFECT_MOVE | DROPEFFECT_COPY);
  57. }
  58. else
  59. *pdwEffect = DROPEFFECT_NONE;
  60. return S_OK;
  61. }
  62. /*----------------------------------------------------------
  63. Purpose: IDropTarget::DragOver method
  64. */
  65. STDMETHODIMP CMenuBandDropTarget::DragOver(DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
  66. {
  67. *pdwEffect &= (DROPEFFECT_MOVE | DROPEFFECT_COPY);
  68. return S_OK;
  69. }
  70. /*----------------------------------------------------------
  71. Purpose: IDropTarget::DragLeave method
  72. */
  73. STDMETHODIMP CMenuBandDropTarget::DragLeave(void)
  74. {
  75. // Kill timer, release object
  76. return S_OK;
  77. }
  78. /*----------------------------------------------------------
  79. Purpose: IDropTarget::Drop method
  80. */
  81. STDMETHODIMP CMenuBandDropTarget::Drop(IDataObject * pdtobj, DWORD grfKeyState, POINTL pt,
  82. DWORD * pdwEffect)
  83. {
  84. if (*pdwEffect & (DROPEFFECT_MOVE | DROPEFFECT_COPY))
  85. {
  86. if (_dwFlagsMBIF & SMIF_SUBMENU)
  87. {
  88. // We don't allow drops on submenu items. Must go into
  89. // cascaded menu.
  90. *pdwEffect = DROPEFFECT_NONE;
  91. }
  92. }
  93. return S_OK;
  94. }