views:

145

answers:

2

I am trying to implement a lazy drag and drop operation. I want to show a listview with files to my user, when the user drags a file and drops it into a folder the content should be downloaded and delivered.

I am using the IDataObject interface, but my problem is that the GetData() method is queried way too early. For instance a drag over the desktop (without any drop involved) will query the GetData() method a couple of times. And each of these calls starts the download of the file :/

Now, my question is: What's wrong here - why is the GetData() method called without any drop? Is there another way to implement lazy drag & drop operations in .net?

+1  A: 

Maybe this could work for you...

On every occurrence of the GetData() do this:

  • you'll need some kind of a timer here.
  • if your timer is already active, kill it.
  • create and start a new timer. Make it 1sec or determine its duration from the experiment.
  • on timer event do what has to be done.

I use similar procedure on many occasions where such workaround is needed.

Daniel Mošmondor
The problem here is that the drag could be canceled at all.
tanascius
Daniel Mošmondor
tanascius
If you didn't resolve that by now, I can try to go your way and solve the issues you have...
Daniel Mošmondor
+1  A: 

I think GetData is being called so that the (potential) drop target can determine whether or not it can accept the (potential) drop item(s). Have you considered using a shell extension?

gkrogers
As far as I understand the [GetDataPresent](http://msdn.microsoft.com/en-us/library/f0z723wb.aspx) method should be called at first. Still trying ...
tanascius