Do you have example how to drag drop C++ object?

Home Forums DropMaster Do you have example how to drag drop C++ object?

Viewing 3 reply threads
  • Author
    Posts
    • #2927
      Andrew Bond
      Participant

        I am using DropMaster 2.5.2 to simplify drag/drop operations within our applications, with great success. (The 32-bit app is built with C++Builder 10.4, Sydney.)

        However, I am struggling to implement drag/drop of objects between different instances of the same application.

        What I have in my app is as follows:

        For the sending part of my app, I have an event handler DragSourceRenderCustomFormat that streams my C++ object to memory using memcpy and then assigns the address of that memory to the FormatContent argument that is passed into the handler.

        For the receiving part of my app, I have an event handler DropTargetDrop that receives the data sent via FormatContent via its DropText argument. Is that correct?

        But I am unsure what to do next to reinstate the C++ object from the passed data, given that this object is not simple (i.e. is is an instance of a derived class with several parent classes).

        Do you have a C++ example of the above that I could use to get me over this hurdle? I cannot find anything in the examples that come with DropMaster.

        Thanks in advance for any help you can give.

        Andrew Bond

         

         

         

      • #2932
        Andrew Bond
        Participant

          Does anyone from Raize Software monitor these forums?

        • #2969
          Ray Konopka
          Keymaster

            Hi Andrew,
            I apologize for the long delay. Apparently, the notification of new posts to the forums stopped sending out notifications.

            Unfortunately, we do not have any additional C++ examples outside the ones that are distributed with the components. However, it appears that your real question is more of a data marshalling question rather than a drag and drop question.

            For instance, it appears that the drag data is being transmitted to the destination app. However, given that you are copying your object’s data using memcpy and using the address to send the data, I’m not sure what you will be able to do with that on the receiving end. That is, I think a better approach would be to package up the object information you want to drag into some well defined format (e.g. JSON, xml, etc), and then provide that in the drag operation. Then on the receiving side, you would receive the well defined object information. You could then create a new instance of your object and then use the drag payload to populate the object’s properties.

            Hope this helps, and again I apologize for the delay in responding.

            Ray

          • #2971
            Andrew Bond
            Participant

              Ray

              Thanks for the reply. I thought it was strange that you had not replied – most unusual.

              I have resolved the issue now, pretty much along the lines that you have suggested. I stream the object to XML format, send the XML via DropMaster to the second instance, and then re-create the object there based on the received XML.

              So this question is now answered.

              Andrew

               

               

          Viewing 3 reply threads
          • You must be logged in to reply to this topic.