怎样用VB抓图并将其保存在指定的文件里
2个回答
展开全部
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) 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 Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Sub Command1_Click()
Dim hdc As Long, hWN As Long
Picture1.Width = Screen.Width
Picture1.Height = Screen.Height
Picture1.AutoRedraw = True
hWN = GetForegroundWindow()
hdc = GetDC(hWN)
sx = Screen.Width / Screen.TwipsPerPixelX
sy = Screen.Height / Screen.TwipsPerPixelY
BitBlt Picture1.hdc, 0, 0, sx, sy, hdc, 0, 0, vbSrcCopy
ReleaseDC 0, hdc
Picture1.AutoRedraw = False
SavePicture Picture1.Image, App.Path & "\1.jpg"
End Sub
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 Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Sub Command1_Click()
Dim hdc As Long, hWN As Long
Picture1.Width = Screen.Width
Picture1.Height = Screen.Height
Picture1.AutoRedraw = True
hWN = GetForegroundWindow()
hdc = GetDC(hWN)
sx = Screen.Width / Screen.TwipsPerPixelX
sy = Screen.Height / Screen.TwipsPerPixelY
BitBlt Picture1.hdc, 0, 0, sx, sy, hdc, 0, 0, vbSrcCopy
ReleaseDC 0, hdc
Picture1.AutoRedraw = False
SavePicture Picture1.Image, App.Path & "\1.jpg"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询