VB icon

A Way to take a screenshot

Email
Submitted on: 1/3/2015 4:01:00 PM
By: Steve (from psc cd)  
Level: Not Given
User Rating: By 6 Users
Compatibility: VB 5.0, VB 6.0
Views: 927
 
     This code simply takes a picture of your desktop or a screenshot. I guess if you wanted to you could use this to view the desktop of a computer over a network, although that would be a bit slow. I hope this code is of some interest to some people Hope this helps.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :A Way to take a screenshot
'**************************************
'Check out my site at http://www.vbtutor.com
'Thanks
Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Integer, ByVal x As Integer, _
ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer, ByVal _
hSrcDC As Integer, ByVal xSrc As Integer, _
ByVal ySrc As Integer, ByVal dwRop As _
Long) As Integer
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Public Const SRCCOPY = &HCC0020
Public Const SRCAND = &H8800C6
Public Const SRCINVERT = &H660046
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: A Way to take a screenshot
' Description:This code simply takes a picture of your desktop or a screenshot. I guess if you wanted to you could use this to view the desktop of a computer over a network, although that would be a bit slow. I hope this code is of some interest to some people Hope this helps.
' By: Steve (from psc cd)
'
' Assumes:'Check out my website at http://www.vbtutor.com
'Thanks
Set the Form properties to the following:
AutoRedraw True 
BorderStyle 0 - None 
WindowState 2 - Maximized 
'**************************************

'Add this code to the form_load event
'or whatever you want to make it occur
'Get the hWnd of the desktop
DeskhWnd& = GetDesktopWindow()
'BitBlt needs the DC to copy the image. So, we
'need the GetDC API.
DeskDC& = GetDC(DeskhWnd&)
BitBlt Form1.hDC, 0&, 0&, _
Screen.Width, Screen.Height, DeskDC&, _
0&, 0&, SRCCOPY
'This code was requested by 1 visitor to my site
'Check out my site at http://www.vbtutor.com
'Thanks


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.