Run dragdrop implementation after calling DoDragDrop method

I struggled with this for quite some time.

My application contains a list view filled with the names of files that are located on the server.

I am trying to implement drag and drop functions, so the user can drag and drop files from my application to their local computer.

To do this, first upload the files to a temporary location, and then call the DoDragDrop () method of my application.

The problem is that I want to complete the boot process only after the DoDragDrop method is called.

I tried every event related to drag and drop methods (GiveFeedback, ItemDrag, etc.) but nothing works

so basically I need an event raised after DoDragDrop.

any ideas

+4
source share
3 answers

I don’t know how to do this in .NET, but with normal Win32 programming, an object that implements the IDataObject interface can also implement the IAsyncOperation interface. IDropTarget can then use this interface to perform drag-n-drop in the background thread so that the source and target do not block during the actual transfer. The only problem is that the goal, not the source, decides whether to use it or not.

An alternative is to use “optimized relocation,” where IDataObject provides file names and IDropTarget moves files directly.

MSDN has information about this: Processing Shell Data Transfer Scripts .

Of course, this all the same means that you need to upload files before starting drag-n-drop. Cannot perform drag-n-drop to determine the target, and then load later. However, you can have IDataObject hold CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS (described here: Clipboard shell formats ), where CFSTR_FILEDESCRIPTOR populated from the information you used to populate the ListView, and CFSTR_FILECONTENTS uses the timestamped interfaces the actual delete operation, not before it. At least that’s how you upload only those files that really want the target, and you can skip the rest.

Pair with IAsyncOperation, and this can give you the final effect you're looking for.

+3
source

Here is an example that might look like a Remy solution ...

+3
source

Have you checked the dragdrop event? This is an event that rose with the successful fall of your control.

Update. As long as you need to drag and drop your files into the explorer with rendering delay, you can read the next article (implementation of your own drag-n-drop shell in C #). Using the information and code from this article, you can create your own implementation of IDataObject with support for deferred rendering.

0
source

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


All Articles