Solved

Drag data from C++  (OLE) dialog drop into C# winform

Posted on 2010-11-16
4
499 Views
Last Modified: 2012-05-10
Hi

No response from my original question so I'm reposting with more detail.  Hope it helps.

Having spent a couple of hours trawling throught the net with no sucess, I'm finally posting here with the hopes of some help.

I have a C++ multi dialog application which starts a dragdrop using the OLE RegisterDragDrop.  This application also has handers for the drop on othe dialog pages and everything works fine.  

I am now upgrading this application with a C# winform being attached to a C++ Dialog.  Everything works fine, and is being displayed as intended.

However, I can't get the drop to work from the old C++ (OLE) application to the new C# one.  

When the drop event is fired, I can see the Type of the data is a DataObect but any attempt I've made so far in actually getting the data being dragged has resulted in a null.

Can anyone point me to an example of how to get the data being dragged from an OLE application and being dropped into a C# application.

Hope that's enough info, if not please post and I'll try to provide some more.  I'm just looking for pointers at the moment rather than a solution.

Cheers
Hank
0
Comment
Question by:HankSloka
  • 2
4 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 34153554
Why don't you write a description for the data object in a file and when the drop event is fired read that specific file?
Just a quick suggestion...:-)

George Tokas.
0
 

Author Comment

by:HankSloka
ID: 34153649
Thanks George

Unfortunately, even though this is a viable solution, making ANY changes to the existing code would result in a massive regression test in QA which is not an acceptable option.  I really need a way to get at the OLE data being dragged using C#.

Thanks anyway.

Cheers
Hank
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 34155802
I would be curious what data formats are present when you drag and drop to the Form (e.Data.GetFormats()).
0
 

Author Closing Comment

by:HankSloka
ID: 34162953
Although you didn't actually "solve" my problem, your question put me on the right lines!  I can now get the data into an object by using:-

            string[] frmts = e.Data.GetFormats();
            object o = e.Data.GetData(frmts[0]);

From there I can work on the memory stream and get the data out.

Many thanks :)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now