Solved

VB5 Screen capture

Posted on 1997-10-23
6
315 Views
Last Modified: 2008-03-06
How can I capture the screen?
0
Comment
Question by:Evil
6 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1438585
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
 

Author Comment

by:Evil
ID: 1438586
I'd rather not use an external program.

Are there any components out there that can capture the screen automatically?
0
 
LVL 3

Expert Comment

by:ChrisLewis
ID: 1438587
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 5

Expert Comment

by:dirtdart
ID: 1438588
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
 

Author Comment

by:Evil
ID: 1438589
how do i set that to null?
0
 
LVL 5

Accepted Solution

by:
dirtdart earned 50 total points
ID: 1438590
Dim x as long
x = GetDC()

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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