Clipboard issue. Can't get MetaFilePict data.
I am having an issue getting certain data off the clipboard in both Visual Basic 2003 and 2005 that wasn't an issue in VB6.
Here is how it works. We have a MapGuide ActiveX viewer control that AutoDesk uses to show autocad maps. They have a CopyMap function in this control that copies the map image to the clipboard.
In VB6 I can use the following line of code and get the image off the clipboard and place it in a picture control:
Clipboard.GetData(vbCFEMetafile)
In VB .Net however I am having an issue. After the CopyMap function is called, I do the following:
Dim lobjDataObjectAs IDataObject
Dim lobjImageAs Drawing.Image
lobjDataObject = Clipboard.GetDataObject()
lobjImage = lobjDataObject.GetData(DataFormats.MetafilePict)
While debugging, after the GetDataObject call, I check the return from the DataObjects GetFormats routine in the watch window. This tells me there is a MetaFilePict and and EnhancedMetaFile on the clipboard.
I can also go into an application like Paint or Word and paste the map image in those apps so I know for a fact the image is on the clipboard. The GetFormats indicates there is a metafilepict on the clipboard, yet the lobjDataObject.GetData(DataFormats.MetafilePict) returns an empty (Nothing) object. The watch window also displays a value of nothing if I place lobjDataObject.GetData(DataFormats.MetafilePict) as a watch value.
Just as a side note. I know the code above works because if I do a print screen and change the dataformat to Bitmap, I get a bitmap image back. I appear to just be having a problem with the type of data on the clipboard.
Can someone help me out on this problem.

