How to drag and drop many files without using system resources?

One of the functions I'm working on is the ability to drag and drop objects from the main window and transfer them to Windows Explorer as files.

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

However, since we are currently working on supporting the number of objects at the enterprise level, we see large delays, sometimes leading to freezes or possible crashes when a user tries to drag a lot of objects from our application into Windows Explorer.

I assume this is because OnRenderGlobalData() is called quite a few times, and, of course, each time it has to iterate over objects that are being dragged and save them as files.

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

Is there a way to speed up our application when a user tries to drag a lot of objects into Windows Explorer, preferably moving the save loop to a place where it can be executed only once when the actual crash occurs

+6
source share
2 answers

Instead of creating files, drag the virtual data that is generated during the drag and drop. Offer CFSTR_FILEGROUPDESCRIPTOR and CFSTR_FILECONTENTS. Here is an example .

+5
source

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

0
source

Source: https://habr.com/ru/post/893838/


All Articles