# Visual Basic > Visual Basic 6 and Earlier >  COPY image in clipbord and label value

## luca90

I just have an image in picturebox1 and label named LNOME with the name of image.
possible with a right mouse button click to copy the image from picture box in clicpboard memory with the name of label LNOME?
then message "image ready in memory!"
tks.

----------


## Elroy

That's an interesting question.  For any single clipboard entry, there's always the possibility for several different clipboard formats.  You might be able to put the image in the clipboard as an image, and then use the text format for that same entry for your label.

VB6 isn't going to natively do that though.  It's going to take some clipboard API work to actually get that done, if it can be worked out.

----------


## fafalone

If you read through this thread, you'll find code for reading/adding various image and text formats, for both image files and raw image data including transparency with CF_DIBV5, but it's not very organized, and it's pretty complicated stuff. 

This thread has a demo project that's pretty close to what you want (drag image+text between pictureboxes), but uses the file-based CF_PNG format rather than raw bitmap data not in a file.

----------


## Arnoutdv

> I just have an image in picturebox1 and label named LNOME with the name of image.
> possible with a right mouse button click to copy the image from picture box in clicpboard memory with the name of label LNOME?
> then message "image ready in memory!"
> tks.


What's the purpose for putting the image *and* the filename on the clipboard?
Is it for usage in other programs or to be used from within your own application?

----------


## couttsj

The simplest way to get an image into the clipboard is to give the image the focus and then use [Alt-Print Screen].

J.A. Coutts

----------


## wqweto

> The simplest way to get an image into the clipboard is to give the image the focus and then use [Alt-Print Screen].
> 
> J.A. Coutts


What about the LNOME part? How do you name your screen capture LNOME?

Otheriwse *Clipboard.Clear : Clipboard.SetData Image1.Picture* would do what OP wants but I guess he already knows this.

cheers,
</wqw>

----------


## Brenker

The following are just for reference, may or may not be directly relevant to you:

-- PrnScreen will invariably result in strange alpha values in the alpha bytes of the image which are not from the original file.  As such, if it is known that the image is originated from PrnScreen, just discard the alpha values in the pasted clipboard image.

-- To store the image of the original file, 32-BPP DIB is preferred to PictureBox as it is capable of storing the original alpha values if any.

-- The word "label" is mentioned throughout the earlier postings.  I guess it is meant to be the name of "Custom Format" of the image newly put into the clipboard.  As it is impossible to tell whether a current e.g. "CF_BTMAP" item is from PrnScreen or not, there are quite a number of softwares which may have "PNG" as the "Custom Format", as distinguished from otherwise the predefined clipboard image formats (such as the said "CF_BITMAP").  Here is an example, some of you know PhotoDemon of Tanner's, now if you load a 32-BPP image and copy it as 32-BPP to clipboard, there will be a "PNG" entry in the Clipboard Viewer/Listing (if you enumerate in your own progrom), in addition to "CF_BITMAP", "CF_DIB" and "CF_DIBV5".  You can safely select the said "PNG" item and may have a 32-BPP clipboard image alright.

-- My own Clipboard.cls is built on "CustomClipboard.cls", v.2.0, dated Mar 9, 1998, authored by SP McMahon of vbAccelerator (www.vbaccelerator.com).  Some updates might have taken place over the years, but the bulk of the original remains valid.

----------


## dilettante

Seems pretty simple.  What did I miss?

I don't see any special requirements here about transparency or preserving the source file format of the PictureBox image.  I'd assume the source is probably JPEG from a file or a database or somewhere.

To keep it simple and small I'll use a GIF source image and Image controls here, since I don't see anything that benefits from a big fat PictureBox either.  However that has nothing to do with copying or pasting.



```
Option Explicit

Private Sub mnuEditCopy_Click()
    With Clipboard
        .Clear
        .SetText Label1.Caption, vbCFText
        .SetData Image1.Picture, vbCFBitmap
    End With
    mnuEditCopy.Enabled = False
    mnuEditPaste.Enabled = True
End Sub

Private Sub mnuEditPaste_Click()
    With Clipboard
        Label2.Caption = .GetText(vbCFText)
        Set Image2.Picture = .GetData(vbCFBitmap)
    End With
    mnuEditPaste.Enabled = False
End Sub
```

----------


## Elroy

Interesting, I thought a SetData following a SetText would have cleared the SetText.  I guess it's never too late to learn something new about VB6.

----------

