Drag-Drop and two forms. How can I determine when a crash occurred in an external application

I have WinForm, where the user has the ability to drag an item from it to another application. In my case, the second application is SolidWorks. I have no problems with the work of the working part. A user can drag a part from my application onto a SolidWorks drawing, but I want to close my WinForm when the user drops an element into the drawing.

Is there some kind of event where I'm missing somewhere? QueryContinueDrag doesn't seem to be that way. I can drop the part all day, but QueryContinueDrag does not work on a drop.

EDIT: Here is a sample code that I use to start a drag and drop operation. I just don't know when the crash occurs in another application.

 string[] fList = new string[1];
fList[0] = @"C:\block.sldblk";
DataObject dataObj = new DataObject(DataFormats.FileDrop, fList);
DragDropEffects eff = DoDragDrop(dataObj, DragDropEffects.Link | DragDropEffects.Copy);
+3
source share
2 answers

It is best to use IDataObject as your data in the DoDragDrop () call.

Instead of directly inserting the data you need, create a class that inherits from IDataObject to store your data. When the user "rolls" the part, then the "GetData" IDataObject method is called. You can use this to set a flag to close a form or inform the user that a crash has occurred.

Note that there is already an implementation of IDataObject - DataObject. Usually it is much easier to expand or use than try to create your own.

EDIT: , DataObject, , GetData, .

+3

DoDragDrop() . DragDropEffects.None, .

+2

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


All Articles