'捕捉整个屏幕图象 hDCD:目标HDC DW:目标宽度,DH:目标高度
Private Sub CaptureScreen(hDCD As Long, DW As Long, DH As Long)
Dim hWndScreen As Long
Dim hDCSrc As Long, hDCMemory As Long, hBmp As Long, hBmpPrev As Long
Dim w As Long, h As Long
Dim retval As Long
'获得桌面的窗口句柄
hWndScreen = GetDesktopWindow()
hDCSrc = GetWindowDC(hWndScreen)
w = Screen.Width / 15
h = Screen.Height / 15
Option Explicit
Private Declare Function StretchBlt Lib "gdi32" (ByVal hDC 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Integer
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function BitBlt Lib "gdi32" (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 Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hDC As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
Dim flag As Boolean
Private Sub Form_Load()
Picture2.Width = Screen.Width
Picture2.Height = Screen.Height
Picture2.Top = 0
Picture2.Left = 0
Form1.Width = Screen.Width
Form1.Height = Screen.Height
Picture1.Width = Screen.Width
Picture1.Height = Screen.Height
flag = False
End Sub
'捕捉整个屏幕图象 hDCD:目标HDC DW:目标宽度,DH:目标高度
Private Sub CaptureScreen(hDCD As Long, DW As Long, DH As Long)
Dim hWndScreen As Long
Dim hDCSrc As Long, hDCMemory As Long, hBmp As Long, hBmpPrev As Long
Dim w As Long, h As Long
Dim retval As Long
'获得桌面的窗口句柄
hWndScreen = GetDesktopWindow()
hDCSrc = GetWindowDC(hWndScreen)
w = Screen.Width / 15
h = Screen.Height / 15
Private Sub PaintCursor(hDCD As Long)
Dim CursorPos As POINTAPI
Dim CursorPic As StdPicture
Dim hwndCursor As Long
GetCursorPos CursorPos
hwndCursor = GetCursor
DrawIconEx hDCD, CursorPos.x, CursorPos.y, hwndCursor, 0, 0, 0, 0, DI_NORMAL
'StretchBlt Picture2.hdc, 0, CursorPos.Y, 32, 32, Picture3.hdc, 32, 0, -32, 32, vbSrcCopy
End Sub
Private Sub Timer1_Timer()
CaptureScreen Picture2.hDC, Picture2.Width / 15, Picture2.Height / 15
End Sub
上面是我所有的代码
'捕捉整个屏幕图象 hDCD:目标HDC DW:目标宽度,DH:目标高度
Private Sub CaptureScreen(hDCD As Long, DW As Long, DH As Long)
Dim hWndScreen As Long
Dim hDCSrc As Long, hDCMemory As Long, hBmp As Long, hBmpPrev As Long
Dim w As Long, h As Long
Dim retval As Long
'获得桌面的窗口句柄
hWndScreen = GetDesktopWindow()
hDCSrc = GetWindowDC(hWndScreen)
w = Screen.Width / 15
h = Screen.Height / 15