开发者

Implement lazy drag & drop

开发者 https://www.devze.com 2023-01-15 21:57 出处:网络
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 开发

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?


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.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消