vb 求”当前窗体“截图源码 ,并可以保存到文件 每秒钟截几张,越简单越好。

 我来答
男人海洋_2009
2013-01-27 · TA获得超过520个赞
知道小有建树答主
回答量:484
采纳率:0%
帮助的人:387万
展开全部
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 GetActiveWindow Lib "user32" () As Long
Dim a
Private Sub Command1_Click()
a = 0
Timer1.Enabled = True
End Sub
Private Sub Form_Load()

On Error Resume Next

Me.Height = Screen.Height
Me.Width = 5000

MkDir "D:\zt" '建文件夹
Me.AutoRedraw = True
Pic1.AutoRedraw = True
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
a = a + 1
Me.Hide
If a = 3 Then '三秒后开始抓屏

BitBlt Me.hdc, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
'BitBlt Me.hDC, 0, 0, 200, 200, GetDC(GetActiveWindow), 100, 100, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "D:\zt\" & Format(Now, "yyyymmddhhmmss") & ".BMP"
'Pic1.Picture = sFile
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub

自己再修改修改时间,保存路径等
祝你好运!
追问
不行啊,用不了,截图不起,别说截当前窗口了!!!
追答
我在我的电脑上调试没问题呀!
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式