Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / June 2008



Tip: Looking for answers? Try searching our database.

How to copy a picturebox.picture into clipboard?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boris Danner - 26 May 2008 15:16 GMT
I do some drawing to a picturebox and thought I could move
the content to the clipboard for later use in Word like
this:

PIC.AutoRedraw=true
...draw something to PIC like PIC.Line (...)-(...)
Clipboard.SetData PIC.Picture, vbCFBitmap

Why doesn't this work? It doesn't return an error but it
doesn't store anything in the clipboard.
senn - 27 May 2008 04:50 GMT
>I do some drawing to a picturebox and thought I could move the content to
>the clipboard for later use in Word like this:
[quoted text clipped - 5 lines]
> Why doesn't this work? It doesn't return an error but it doesn't store
> anything in the clipboard.

Begin with
Clipboard.Clear
And when using format konstants you must have
parenthesis around it. That is: (vbCFBitmap)
And moreover, you have no PIC.Picture in the
pictureBox - right ?
Try using PIC.Image instead.
Boris Danner - 28 May 2008 10:41 GMT
>> PIC.AutoRedraw=true
>> ...draw something to PIC like PIC.Line (...)-(...)
[quoted text clipped - 10 lines]
> pictureBox - right ?
> Try using PIC.Image instead.

Hmm, thank you for your answer.
With .image it works perfectly.
Of course, in a picturebox there is also .picture available
but only as sub-object with its properties .Handle, .height,
ans so on, but not including an image property, so there was
no error generated. Maybe pictureboxes didn't have this
object in VB5, I could swear that I referred to the image
content by .picture some years ago. Nevertheless, thank you.

Hmm, it works witth Clipboard.SetData PIC.Image,vbCFBitmap
without paranthesis - what should they be for?
senn - 28 May 2008 17:07 GMT
>>> PIC.AutoRedraw=true
>>> ...draw something to PIC like PIC.Line (...)-(...)
[quoted text clipped - 21 lines]
> Hmm, it works witth Clipboard.SetData PIC.Image,vbCFBitmap without
> paranthesis - what should they be for?

Good, you got it working. I' m also using VB5
and don't know if any difference to VB6. The
picture and image properties are related to
different layers.
Though, as you use the image property setting
some drawing to the Clipboard, you're using
the picture property to set the drawing back
to the picturebox. Look an example below,
that uses two pictureboxes on a form. It draws
a circle on picture1, sets it on the clipboard, then
clears the pictureboxes and puts the circle back
on both pictureboxes.
As you found out, you don't necessarily have to use the
parenthesis. -VB5 Books on Line tell one to
use these - but don't tell why.

You should look at
microsoft.public.vb.general.discussion
about a 20 lines down from top you'll find
the subject line: Picture this
Read Larrys answer and use the site he pointed
to.
/senn

Option Explicit

Private Sub Form_Load()
   Picture1.AutoRedraw = True
   Picture2.AutoRedraw = True
   Picture1.Circle (2000, 1600), 1000
   Clipboard.Clear
   Clipboard.SetData Picture1.Image, (vbCFBitmap)

   'Or one of the two below works as well
   'Clipboard.SetData Picture1.Image, vbCFBitmap
   'Clipboard.SetData Picture1.Image

   Picture1.Cls
   Picture2.Cls
   Picture1.Picture = Clipboard.GetData
   Picture2.Picture = Clipboard.GetData
End Sub
Lorin - 07 Jun 2008 16:52 GMT
() means value of.  i.e. passing a value not a pointer (ByRef)

>>>> PIC.AutoRedraw=true
>>>> ...draw something to PIC like PIC.Line (...)-(...)
[quoted text clipped - 65 lines]
>    Picture2.Picture = Clipboard.GetData
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.