VB 截屏的API函数是什么
答案:2 悬赏:10 手机版
解决时间 2021-11-10 06:19
- 提问者网友:温旧梦泪无声
- 2021-11-10 01:44
VB 截屏的API函数是什么
最佳答案
- 五星知识达人网友:鸠书
- 2021-11-10 02:56
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 Sub Command1_Click()
Picture1.AutoRedraw = True
BitBlt Picture1.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy '抓屏
Dim sFile As String
sFile = App.Path & "\" & Format(Now, "yyyy.mm.dd hh.mm.ss") & ".BMP"
Set Picture1.Picture = Picture1.Image
Picture1.AutoRedraw = False
SavePicture Picture1.Picture, sFile '保存
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 Sub Command1_Click()
Picture1.AutoRedraw = True
BitBlt Picture1.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy '抓屏
Dim sFile As String
sFile = App.Path & "\" & Format(Now, "yyyy.mm.dd hh.mm.ss") & ".BMP"
Set Picture1.Picture = Picture1.Image
Picture1.AutoRedraw = False
SavePicture Picture1.Picture, sFile '保存
End Sub
全部回答
- 1楼网友:狂恋
- 2021-11-10 04:12
如果是全屏幕的话,这样最方便
把他加在定时器在修改相关的保存语句就可以了
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,ByVal bScan As Byte, ByVal dwFlags As Long,ByVal dwExtraInfo As Long)
Const theScreen = 1
Const theForm = 0
Private Sub Command1_Click()
Call keybd_event(vbKeySnapshot, theForm, 0, 0)
'若theForm改成theScreen则Copy整个Screen
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
再利用相关代码将picture中的图片输出为所需要的格式即可实现截图。
缺点:无法实现对指定窗口的截图控制。
把他加在定时器在修改相关的保存语句就可以了
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,ByVal bScan As Byte, ByVal dwFlags As Long,ByVal dwExtraInfo As Long)
Const theScreen = 1
Const theForm = 0
Private Sub Command1_Click()
Call keybd_event(vbKeySnapshot, theForm, 0, 0)
'若theForm改成theScreen则Copy整个Screen
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
再利用相关代码将picture中的图片输出为所需要的格式即可实现截图。
缺点:无法实现对指定窗口的截图控制。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯