How to Capture the Screen
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 'Graphics - How to Capture the Screen Option Explicit 'Add a CommandButton, a PictureBox to your form. Enlarge the PictureBox and make it wide. 'When you press the button, the program will capture the screen image, and draw it in the PictureBox. 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 Private Sub Command1_Click() Dim DeskhWnd As Long, DeskDC As Long DeskhWnd& = GetDesktopWindow() DeskDC& = GetDC(DeskhWnd&) 'You can do the same with form instead of Picture box BitBlt Picture1.hdc, 0&, 0&, Screen.Width, Screen.Height, DeskDC&, 0&, 0&, SRCCOPY End Sub |