VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Take a screenshot (BitBlt and DC's)

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 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

Rate Take a screenshot (BitBlt and DC's)

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

Download this snippet    Add to My Saved Code

Take a screenshot (BitBlt and DC's) Comments

No comments have been posted about Take a screenshot (BitBlt and DC's). Why not be the first to post a comment about Take a screenshot (BitBlt and DC's).

Post your comment

Subject:
Message:
0/1000 characters