Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to copy the content of a PictureBox to the clipboard???

Posted on 2003-02-28
10
Medium Priority
?
305 Views
Last Modified: 2013-11-26
I've got a picture box that I use as a container and I'd like to copy its content to the clipboard. It's fine if I use this picture box as a picture but not as a container... Please help !! Thanx
0
Comment
Question by:twinchouche
10 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 8042623
Clipboard.clear
Clipboard.setData Picture1.Picture

OR

Clipboard.setData Picture1.Image
0
 

Expert Comment

by:AnthonyBlake
ID: 8043580
copy the pointer to the image
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8044036
"copy the pointer to the image "
could you explain it a bit?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:MDockery
ID: 8044847
If by the contents of the picture box you mean to grab an image of all the objects in it, then try the BitBlt function. This will grab a graphical representation of an area of the screen. Then you may do with it as as want.

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Command1_Click()
BitBlt Picture2.hDC, 0, 0, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, vbSrcCopy
Picture2.Refresh  'Picture2 has AutoRedraw as True
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8044948
I think you don't need bitblt since he needs to copy to clipboard not another control.
To me, one of both  bobbit's suggestion should do the job.
0
 

Author Comment

by:twinchouche
ID: 8055767
Actually, the problem is the following. I'd like to copy the entire contents of a picturebox. Most of the time, the contents of this picturebox are wider than what is actually displayed on the screen and I want to copy to the clipboard the ENTIRE content of the picturebox.
It seems that the code given by MDockery copies only the contents of the picturebox actually displayed on the screen.
0
 

Author Comment

by:twinchouche
ID: 8056563
Besides, the contents of the picturebox are not drawings but other controls...
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 8057511
The problem is, as long as i know, that there is no way you could use to get a bitmap/picture that is not totally visible. Windows doesn't knows which is "behind the scenes".
I think that, to it, which is not visible doesn't exist.
0
 

Author Comment

by:twinchouche
ID: 8057980
I think you're right Richie. I just read an article about VB pictureboxes and this is one of their limitations.
Thanx guys for your comments.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8058030
I haven't to clarify anything but, it is not a limitation of picturebox but Windows API itself.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question