Clipboard Image Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VB User

    #1

    Clipboard Image Data

    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
  • Patrick Steele [MVP]

    #2
    Re: Clipboard Image Data

    In article <C712C7B0-CE85-4328-B20C-044725044AFF@mi crosoft.com>,
    VBUser@discussi ons.microsoft.c om says...[color=blue]
    > 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[/color]

    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.GetDa taObject()

    If data.GetDataPre sent(DataFormat s.Bitmap) Then
    Dim img As Image = DirectCast(data .GetData(DataFo rmats.Bitmap),
    Image)
    Me.ClientSize = img.Size
    PictureBox1.Loc ation = New Point(0, 0)
    PictureBox1.Siz e = img.Size
    PictureBox1.Ima ge = img
    End If

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

    --
    Patrick Steele
    Microsoft .NET MVP

    Comment

    Working...