1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Private Declare Function BitBlt Lib "gdi32.dll" ( _
ByVal hDestDC As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Const SRCCOPY As Long = &HCC0020
'______________________________________________________________________________
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Sub ScreenShot(Pic As Image)
'Dim Hdl As Long
'Hdl = FindWindowA(vbNullString, Me.Caption)
Pic.PictureSizeMode = 3
Pic.Width = Me.Width
Pic.Height = Me.Height
Pic.Visible = False
BitBlt Pic.hDC, 0&, 0&, Me.Width, Me.Width, GetDC(GetDesktopWindow()), 0&, 0&, SRCCOPY
SavePicture Pic.Image, "C:\ScreenShot.bmp"
End Sub
Private Sub CommandButton1_Click()
ScreenShot Pic
End Sub |
Partager