Search Tools Links Login

Take a screenshot (BitBlt and DC's)

My code here will allow you take a screen shot of the entire screen.

Original Author: Adam Orenstein


Remeber when taking a screen shot the picture gets added to the destinations Image property not its image property. also don't forget to set the Autoredraw property of the destination of the image to True. Thanks!

API Declarations

Public Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hDC As Long) As Long


Public Function CaptureScreen(PicDest As Object)

DeskWnd& = GetDesktopWindow
deskdc& = GetDC(DeskWnd&)

Call BitBlt(PicDest.hDC, 0&, 0&, Screen.Width, Screen.Height, deskdc&, _
0&, 0&, SRCCOPY)

Call ReleaseDC(deskdc&, 0&)

End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 80 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.