Drag N Drop from managed -> unmanaged & vice versa

  • Thread starter Deepak Malkan [Bentley]
  • Start date
D

Deepak Malkan [Bentley]

Our product has implementation both in managed & unmanaged code. So also,
user interface dialogs are both in managed & unmanaged. Currently, I'm
working to support drag & drop across the interop boundaries & am running
into some problems with custom data formats.

So far, I've discovered that if I create a DataObject in managed code for my
custom data format, then on the unmanaged side, I get the DataObject as a
COM object. What is the way to extract the actual data from this COM object?

I've tried various ways to decipher the COM object, including defining my
own unmanaged COM DataObject & calling Marshal.GetObjectForIUnknown to wrap
the unmanaged COM object, but so far I haven't been able to figure out the
proper way to extract my data correctly on the unmanaged end.

I suspect I will run into a similar situation when trying to drag & drop
from an unmanaged dialog to a managed dialog.

I will appreciate any pointers to resolving this problem.

With Regards,

Deepak Malkan
Bentley Systems.
 
P

Peter Huang [MSFT]

Hi

There is tool DataObject Viewer shipped with VS6.
IDataObject Data Object Viewer
DOBJVIEW displays the list of data formats offered by ActiveX and OLE data
objects created by the Clipboard or drag-and-drop operations.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/htm
l/_core_using_viewers_and_spy_programs.asp

You may try to drag the .NET Object onto the tool to see what you will get.

Also can you provide a simple sample which will demostrate what format you
will drag and drop?
Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Deepak Malkan [Bentley]

Peter,

Thank you for your response.

The drag N drop from my object in the managed dialog into DOBJVIEW window
fails.

If I copy my object into the clipboard - using the same dataobject, I get in
DOBJVIEW a list of formats displayed as follows:

System.String
Unknown Clipformat
CF_TEXT
MicroStation Model List

For each format the rest of column are identical - ptr={NULL}, dwAspect =
{Content }, lindex={-1}, tymed={hGlobal}

Of the four formats listed, my program has actually put only two - the first
"System.String" & the last "MicroStation Model List".

My sample code is as follows (in managed C++):

wchar_t * xmlText;
.... Allocate & build xmlText ...

NSForms::DataFormats::Format * modelDataFormat =
NSForms::DataFormats::GetFormat(S"MicroStation Model List");
NSForms::DataObject * dataObject = new NSForms::DataObject ();
dataObject->SetData (modelDataFormat->Name, true, new
System::String(xmlText));
dataObject->SetData (new System::String (xmlText));

(NSForms - is a namespace alias for System::Windows::Forms)

- Deepak.
 
D

Deepak Malkan [Bentley]

Peter,

Thank you for your response.

The drag operation from my object in the managed dialog to DOBJVIEW fails.

If I copy my object into the clipboard, then I get the folllowing formats
listed in DOBJVIEW:

System.String
Unknown Clipformat
CF_TEXT
MicroStation Model List

The rest of the columns are identical for all the formats - ptd={NULL},
dwApsect={Content }, lindex={-1}, tymed={hGlobal}.

Of the 4 formats, my program has added only 2 - the first (System.String) &
the last (MicroStation Model List).

My sample code to build the dataObject is as follows (in Managed C++):

wchar_t * xmlText;
... Allocate & build xmlText ...

NSForms::DataFormats::Format * modelDataFormat =
NSForms::DataFormats::GetFormat(S"MicroStation Model List");
NSForms::DataObject * dataObject = new NSForms::DataObject ();
dataObject->SetData (modelDataFormat->Name, true, new System::String
(xmlText));
dataObject->SetData (new System::String (xmlText));

(NSForms is a namespace alias for System::Windows::Forms).

- Deepak.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top