I have written a small application for =2ENET 1=2E1 which contains a=
control that implements drag and drop=2E The control in question=
is derived from TreeView and the object being dragged is an=
instance of a simple private Serializable class=2E
When the user drags with the right-mouse button I put up a=
ContextMenu in OnDragDrop with the items "Copy", "Move" and=
"Cancel", like Windows Explorer=2E The result determines how I do=
the drop=2E I copy an appropriate value back into=
DropEventArgs=2EEffect and then copy or abandon the drop=2E
If I drag and drop within the same instance of the application it=
works fine=2E
If I drag from one instance and drop into another instance of the=
application then it works - as in the context menu appears, the=
copy is made etc=2E - but then when OnDragDrop in the instance=
handling the drop tries to return it gets an exception:
>>>>>>>>>>
An unhandled exception of type=
'System=2ERuntime=2EInteropServices=2ESEHException' occurred in=
system=2Ewindows=2Eforms=2Edll
Additional information: External component has thrown an=
exception=2E
<<<<<<<<<<
If I change the code so that I just copy instead of putting up=
ContextMenu then it works, the copy goes ahead with no=
exceptions=2E
Has anyone managed to pop up a context menu in the instance=
handling the drop without getting this? Does anyone know what is=
causing it? Do I have to go through some weirdness to get the=
dragging instance to show the menu and pass the result to the=
dropping instance? Is it my use of ContextMenu=2EShow, do I have=
to side-step it and use the Windows API directly to show a=
context menu?
I can certainly work around this but it'd be nice to get it=
working as intended=2E
Thanks in advance,
Andrew
-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>sLJYQ8TuhEit+I8Yj9m+0Q=3D=3D</Id>