Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell if a drag and drop operation failed?

It seems to me there is no way to detect whether a drag operation was successful or not, but there must be some way. Suppose that I want to perform a "move" from the source to the destination. If the user releases the mouse over some app or control that cannot accept the drop, how can I tell?

For that matter, how can I tell when the drag is completed at all?

I saw this question, but his solution does not work for me, and e.Action is always Continue.

like image 877
devios1 Avatar asked Feb 02 '09 20:02

devios1


2 Answers

I'm not sure if that can help you, but DoDragDrop method returns final DragDropEffects value.

var ret = DoDragDrop( ... );
if(ret == DragDropEffects.None) //not successfull
else // etc.
like image 128
cz_dl Avatar answered Oct 05 '22 23:10

cz_dl


Ah, I think I've got it. Turns out the call to DoDragDrop is actually synchronous (how lame), and returns a value of DragDropEffects, which is set to None if the op fails. So basically this means the app (or at least the UI thread) will be frozen for so long as the user is in the middle of a drag. That does not seem a very elegant solution to me.

Ok cz_dl I see you just posted that very thing so I'll give u the answer.

This I don't understand though: how can the destination determine whether the op should be a move or a copy? Shouldn't that be up to the source app?

like image 29
devios1 Avatar answered Oct 06 '22 00:10

devios1