The event fires in the dragdrop source when dragdrop is completed or canceled

I know that usually there is a DoDragDrop method that starts a drag and drop operation. And that there are events (such as DragEnter , DragOver , DragDrop , DragLeave ) that can be processed on the target side.

Are there any events in the dragdrop source that will tell me if the dragdrop operation was completed or possibly canceled?

+4
source share
2 answers

Yes, DoDragDrop () has a return value. It returns DragDropEffects.None if the drop has been canceled.

+6
source

You mean a situation similar to delete-paste in Windows Explorer, where the file is not deleted from the source folder until the Insert operation occurs.

http://msdn.microsoft.com/en-us/library/bb776904(VS.85).aspx#delete_on_paste

Simple answer

If you do this in one instance of the application, this refers to the optimized movement , where you can simply set a local flag (for example, a boolean variable) to determine if it was successful.

Update:. Yes, you can also check the results of the DoDragDrop method to determine whether it was deleted. Just make sure your reset handling code correctly sets the Effect to None if there is an error that completes the crash, otherwise your DoDragDrop code will assume that the crash was successful. This method will work even between two instances of your application.

Hard answer

If you do this between two instances of your application, and you need to transfer more information about whether it was deleted or not, then you need to implement the OLE version of IDataObject so that the application instance, this drop target completes the drag and drop, it can call SetData on the source object to send information about the results. This is difficult to do, but certainly possible.

For more information, see the following links:

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.idataobject.aspx

http://blogs.msdn.com/b/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx

+1
source

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


All Articles