Solved

VB5 Screen capture

Posted on 1997-10-23
6
322 Views
Last Modified: 2008-03-06
How can I capture the screen?
0
Comment
Question by:Evil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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!

 
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

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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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