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 and 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?
"Clicking and dragging" is a way to move certain objects on the screen. To move an object, place the mouse cursor over it, press and hold down the left mouse button, then move the mouse while still holding down the left mouse button.
Put the mouse pointer over the file or folder. Press and hold mouse button 1. Drag the icon to where you want to drop it. Release the mouse button.
How do I Drag and Drop? By default, if you left-click and HOLD the left mouse or touchpad button while moving your mouse pointer to a different folder location on the same drive, when you release the left mouse button the file will be moved to the new location where you released the mouse button.
Instead of creating files, drag virtual data that is generated at drop time. Offer CFSTR_FILEGROUPDESCRIPTOR and CFSTR_FILECONTENTS. Here's an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With