Hi,

i'am a c# developer but I don't have much experience with c++. I'am curious if it is possible and how to add drad & drop functionality to a window of an external application. From my application I start an external application. I want to be able to drag an item(e.g. a rectangle) from my application to the external application.On drop, there would be called a function doing something. Any tricks are allowed.I've been thinking about embedding the external window in a new layered window. Would it be possible and could work for drag&drop? Thanks in advance for any suggestions and maybe some short code example.

I'am curious if it is possible and how to add drad & drop functionality to a window of an external application.

Only of the external application supports drag and drop, and you'd need to figure out how to make drag work between them. This strikes me as a tricky problem, given that drag and drop is internal logic. If the external application doesn't support it in the way you need, you're SOL. Ideally you'd have control over both applications' source code to tailor interaction between them.

Hi,

unfortunatelly I don't have the code of the external application and there is no support for drag and drop. Because of that I was thinking about writing a kind of wrapper - embedding the window of an external application in a window from my application, and then to add drag and drop in the new window(but I don't know how to do this and if it's going to work :) ). I've already done something "similar" in winforms c#. The external application can be started in a control, which is placed in a form in my application. I've placed a hidden, transparent panel with drop functionality over the external control. When the mouse hovers over the control, the transparent panel is set to visible(however it's invisible because it's transpaent :) ) and then I can do drop action on the panel. The user doesn't know about the panel and it looks like the drop were done on the external application. Now I have to do it in c++, without using .net. In c++, there is nothing like a control in winforms.

What deceptikon said. The window manager probably supports drag+drop, (pretty standard these days) but both source and destination applications have to handle the drag and drop events respectively, otherwise nothing will happen such as you want. "Wrapping" the application in another window buys you nothing. Even with C#, your application has to provide a drag and/or drop event handler/call-back.

Member Avatar for iamthwee

Not to mention doing this in c++ is a ballache. You'd most probably have to use win32 and that's a steep learning curve, (I'm assuming this isn't unix based since you mention c#).

Good luck.

Perhaps there is another solution. What type of external app is this? Microsoft or a custom app? Do you really need the drag and drop?

Hi,

I've made id. Almost all day long I've tried different things in c++ and it worked. So, first of all, as I am not c++ developer, my first idea(and the problem description in my first post) wasn't the best one... sorry for that.
For the simplicity of the problem description, let set, that I want to drag item "rectangle" from a treeveiw to an external application, and a rectangle should appear there.

In the end what I did is to drag an item from a treeview from window 1 to window 2 - both comes from my application. The external application is also started from my application, there are also public methods, which I can access. Window 2 is transparent and shown only when drag action begins. It's hidden when the mouse button goes up on window 2. In the onlbuttonup event handler I call a method from the external application to create a rectangle.

Sounds kind of like what we were saying. Glad you got the event handling code working! :-)

And for whatever it's worth, this is serious programming chops! I'm giving you an up vote, if only for your persistence in solving your own problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.