I need to implement a drag&drop mechanism between a C++ .NET application and a Java GUI, in both directions. Is it possible with some standard API or do I need some custom library?

No correct solution


You cannot drag arbitrary objects from one to the other. You must use a format which both understand. In Java these are called DataFlavors, In Windows DataFormats (which are simply identified by name within the win forms .Net world)

Here's a guide for the java end. Here's the MSDN docs related to the Data Formats

It is possible to go very low level and implement complex code on both sides to handle quite complex communication between the differing apps/platforms but if you just want to be able to drag an image from one app to another you will find it easier to start with bitmaps since they are pretty universal.

If you actually want the identifier of the thing represented by the icon to be associated/dissociated and you only want this to work between the two apps in question then simply transferring the identifier as text as normal and have both apps intepret the drag/drop as an event which requires going and getting the same icon and displaying it/removing it along with the associated update.

You will however need to know whether the drag event was successful (to remove the icon from the dragged from app as well) this isn't too hard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow