Clipboard Image Data

G

Guest

Earlier in VB6, the image was copied onto the clipboard from the Image
Processing Program . This image would then be loaded onto the image control
on the VB form using GetData() function.
In VB.NET there is no image control for one and I get a type cast error
while trying to save the contents of the clipboard using GetData() as an image

Any help on this?

VBUser
 
P

Patrick Steele [MVP]

Earlier in VB6, the image was copied onto the clipboard from the Image
Processing Program . This image would then be loaded onto the image control
on the VB form using GetData() function.
In VB.NET there is no image control for one and I get a type cast error
while trying to save the contents of the clipboard using GetData() as an image

For the image, use a PictureBox control. To find out if the clipboard
has a bitmap on it and to pull that bitmap off into the picturebox, use:

Dim data As IDataObject = Clipboard.GetDataObject()

If data.GetDataPresent(DataFormats.Bitmap) Then
Dim img As Image = DirectCast(data.GetData(DataFormats.Bitmap),
Image)
Me.ClientSize = img.Size
PictureBox1.Location = New Point(0, 0)
PictureBox1.Size = img.Size
PictureBox1.Image = img
End If

This is from the "Form_Load" of a quick windows app I did.
 

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