Make your own free website on

Capture Screen Image

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton (named Command1) to your form.
'Add 1 PictureBox (named Picture1) to your form. Enlarge the PictureBox and make it wide.
'When you will press the button, the program will capture the screen image, and draw
'it in the PictureBox.
'Insert the following code to the module :

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

'Insert the following code to your form:

Private Sub Command1_Click()
Dim DeskhWnd As Long, DeskDC As Long
DeskhWnd& = GetDesktopWindow()
DeskDC& = GetDC(DeskhWnd&)
'If you want to draw the captured image on the form rather than the PictureBox,
'replace the 'Picture1' below with the name of the form.

BitBlt Picture1.hDC, 0&, 0&, Screen.Width, Screen.Height, DeskDC&, 0&, 0&, SRCCOPY
End Sub

Go Back