VB5 Screen capture

How can I capture the screen?
EvilAsked:
Who is Participating?
 
dirtdartConnect With a Mentor Commented:
Dim x as long
x = GetDC()

0
 
alamoCommented:
There are are a couple of ways. First of all though, I know of no way to do it tightly integrated into a VB program via API or commercially available control, and this would obviously be the best. new ones pop up all the time though, and if anyone reading this knows of such a beast post a comment and I'll defer.

But this is what I know: If you need simple occasional user-initiated full screen capture you can't beat for simplicity having the user press Shift+PrintScreen to capture the screen to the clipboard. Then in your code use:
Picture1.Picture = Clipboard.GetData(2)
and you now have the screen image.

For some applications that is enough; if it's not I suggest you call an external screen capture program. The one I use is called  HyperSnap... it's very flexible. You can have it snap the whole screen or just a section, it will even scroll windows to capture the portion that's not visible. You can call it with command line arguments or run it and use SendKeys to send it commands. It will save to clipboard or to file, autoincrementing the filename for successive timed captures. You can find it at http://www.hyperionics.com/. I have no relationship with the company other than that of satisfied customer.
0
 
EvilAuthor Commented:
I'd rather not use an external program.

Are there any components out there that can capture the screen automatically?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ChrisLewisCommented:
What are you trying to do???  Is your capture based off of a keystroke, or a timer or a button?

Probably the simpliest way is as alamo stated:
After pressing PrintScreen,
Picture1.picture = Clipbard.Getata(2)

This is pretty standard windows functionality.

chris
0
 
dirtdartCommented:
You can also do a BitBlt to copy whatever section of the screen you want.  The two decarations you need are:

Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (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

hDestDC should be the hDC of the form you want to send to.  x, y, nWidth, nHeight are the upper left corner coordinates and the width and height of the area you want to send to.   hSrcDC is the source destination.  In this case, since it is the screen, you can pass a null value to GetDC to return the hDC of the screen.  xSrc, and ySrc are the upper left corner coordinates of the area you want to capture.  dwRop is a long value that should be set to &HCC0020 for this.

0
 
EvilAuthor Commented:
how do i set that to null?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.