Solved

VB5 Screen capture

Posted on 1997-10-23
6
312 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now