I am developing a Winform application with the .NET 3.5 framework in C #. I would like the user to be able to drag and drop the image from Word 2007. Basically, the user opens docx, selects a picture and drags and drops them into his PictureBox.
I already did the same process with image files from my desktop and from Internet pages, but I can not solve my problem using my metafile. I did some research, but I did not find solutions to my problem.
Here is what I did in my Drag & Drop event:
private void PictureBox_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.MetafilePict)){ Image image = new Metafile((Stream)e.Data.GetData(DataFormats.MetafilePict)); } }
I can get a stream with this code: (Stream) e.Data.GetData (DataFormats.MetafilePict), but I donβt know how to convert it to a metafile or better an Image object.
If you have any ideas or solutions, I will be happy to read it.
Thanks,
source share