开发者

How to drag & drop lots of files without taxing system resources?

One of the features that the program that I'm working on is the ability to drag objects from its main window and drop them onto Windows Explorer as files.

To do this, we override COleDataSource::OnRenderGlobalData() and, when the format is CF_HDROP, we save each object as a file. This works fine when the number of objects is small.

However, as we're now working on supporting enterprise level amounts of objects, we're seeing big delays, sometimes leading to hangs or eventual crashes, when the user tries to drag a lot of objects from our application into Windows Explorer.

My guess is that this is happening because OnRenderGlobalData() is being called quite a number of times, and of course, each time it has to loop through the objects that are being dragged an开发者_StackOverflow社区d save them as files.

I was looking into the idea of overriding OnRenderFileData(), but the problem with that is that it only deals with one file at a time.

Is there any way that I can speed up our application when the user tries to drag a lot of objects onto Windows Explorer, preferably by moving the save loop to a place where it can be executed only once when the actual drop takes place?


Instead of creating files, drag virtual data that is generated at drop time. Offer CFSTR_FILEGROUPDESCRIPTOR and CFSTR_FILECONTENTS. Here's an example.


I have the same problem. My 'solution' is not very clever. I offer drag'n'drop as a convenience for a small number of objects. If the use has selected more than the number of objects that can be well handled, drag'n'drop is disabled and instead the user must select the destination from a folder browser dialog. When the destination is selected, the objects are written as files there, with a progress indicator.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜