2

I need to know is some object being dragged over my Delphi application.

For example: while the user dragging some item from ListView to ListBox, or dragging some file from Explorer into my LitsView, I want to check at any moment is he still dragging or not dragging anymore.

Can I find this without hooking drag events?

Delphi XE

Andrew
  • 3,696
  • 3
  • 40
  • 71
  • 1
    What do you mean by "without hooking drag events" – David Heffernan Jun 22 '12 at 14:57
  • 1
    Have you looked at Anders Melander's "Drag and Drop Component Suite"? I've done very similar things with ease using that in both XE and XE2. Here's the URL: http://melander.dk/delphi/dragdrop/ – James L. Jun 22 '12 at 15:09
  • 1
    @DavidHeffernan I mean I can catch something like OnStartDrag and set boolean flag there but I want some more general solution – Andrew Jun 22 '12 at 15:10
  • I don't see how your proposed solution lacks generality. – David Heffernan Jun 22 '12 at 15:13
  • @DavidHeffernan What about OLE dragging? I thought VCL has some special undocumented flags for this or I can ask Windows API is dragging happens right now. – Andrew Jun 22 '12 at 15:19
  • I handle drag/drop from other apps by implementing IDropTarget. Again, set a flag when `DragEnter` is called, and reset it on `DragLeave` and `Drop`. – David Heffernan Jun 22 '12 at 15:21
  • @DavidHeffernan Um, can you add this as answer? – Andrew Jun 22 '12 at 15:23
  • 2
    @Andrew: there is no API to ask Windows if it is currently dragging something. And Anders' components are based on OLE drag&drop (IDropTarget, etc). – Remy Lebeau Jun 22 '12 at 16:14

1 Answers1

0

I would do this by making a note when the drag process starts, for example when IDropTarget.DragEnter is called. And then reset the flag when the DragLeave or Drop is subsequently called.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490