by Adam Orenstein (6 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
My code here will allow you take a screen shot of the entire screen.
Assumes
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 DeclarationsPublic 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&)
PicDest.Refresh
End Function