470,612 Members | 2,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

Copy MetaFile from the clipboard???

I can get bitmaps from the clipboard, but how do I get Metafiles?
The specific instance I am testing is copying a piece of Word clip-art
into the clipboard and trying to read it in an application. It appears
as a metafile type but isn't recognized as an image.

Given:

DataObject copyObject;
copyObject = (DataObject)Clipboard.GetDataObject();
string[] types = copyObject.GetFormats();

and types contains "MetaFilePict", this fails:
Metafile tmp = (Metafile) copyObject.GetData("MetaFilePict");

with:
'Unable to cast object of type 'System.IO.MemoryStream' to type
'System.Drawing.Imaging.Metafile'.

Also, copyObject.ContainsImage() is false.

How do I get the metafile out?
Jan 27 '08 #1
1 3369
On Sun, 27 Jan 2008 16:07:10 -0800, bern11 <be****@yahoo.comwrote:
I can't get any variants of this to work:
Image tmp = Image.FromStream((System.IO.MemoryStream)
copyObject.GetData("MetaFilePict"));
I was afraid that might be the case. It definitely was for me a year ago
when I tried. :(
I'll check the PInvoke route....
Good luck. I think there should be enough information in that thread to
answer the question, but if not I know I've got some working code around
here somewhere that I can post, if need be.

Pete

Jan 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by andrew | last post: by
2 posts views Thread by George Yefchak | last post: by
7 posts views Thread by lgbjr | last post: by
17 posts views Thread by Steve | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.