Paste a jpeg into VB app

phil2005
02-21-2005, 10:42 AM
I want my user to be able to copy a jpeg, tiff etc from Windows Explorer and paste it in my app, where I will diplay it with GDI+ and move/save it to another location.

clipboard.gettext gives me the file name but no path

Clipboard.GetFormat(vbCFFiles) returns true, but
set iPictureDispObject = clipboard.getdata doesn't return an object

Is there any way of getting sufficient data from the clipboard to create, for example, a GDI+ image that I can save?

OnErr0r
02-21-2005, 11:50 AM
You need to use the correct constant:


If Clipboard.GetFormat(vbCFBitmap) Then Set Picture1.Picture = Clipboard.GetData


From there you can use GdipBitmapFromHBitmap by using Picture1.Image.Handle as the hBitmap to create a GDI+ bitmap.

phil2005
02-21-2005, 12:41 PM
You need to use the correct constant:


If Clipboard.GetFormat(vbCFBitmap) Then Set Picture1.Picture = Clipboard.GetData


From there you can use GdipBitmapFromHBitmap by using Picture1.Image.Handle as the hBitmap to create a GDI+ bitmap.

Thanks, but ...

The file I want to paste is a jpeg, not a bitmap, so getformat gives true for 1, 7 and 13 but not vbCFBitmap (=2)

OnErr0r
02-21-2005, 12:46 PM
Ah, but vbCFFiles would be filename(s), which you would then open using GDI+ LoadFromFile.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum