设为首页收藏本站

SKY外语、计算机论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2648|回复: 0
打印 上一主题 下一主题

VB_屏幕捕获

[复制链接]

16

主题

0

好友

216

积分

中级会员

Rank: 3Rank: 3

生肖
性别

最佳新人 论坛元老

跳转到指定楼层
楼主
发表于 2012-4-28 21:47:37 |只看该作者 |倒序浏览
本帖最后由 sky_yx 于 2015-12-30 14:23 编辑

  1. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
  2. Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
  3. Private Declare Function EmptyClipboard Lib "user32" () As Long
  4. Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
  5. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  6. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  7. 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
  8. Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) As Long
  9. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  10. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  11. Private Declare Function CloseClipboard Lib "user32" () As Long
  12. Dim p1 As String
  13. Sub ScrnCap(Lt, Top, Rt, Bot)
  14. rWidth = Rt - Lt
  15. rHeight = Bot - Top
  16. SourceDC = CreateDC("DISPLAY", 0, 0, 0)
  17. DestDC = CreateCompatibleDC(SourceDC)
  18. BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)
  19. SelectObject DestDC, BHandle
  20. BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Lt, Top, &HCC0020
  21. Wnd = Screen.ActiveForm.hwnd
  22. OpenClipboard Wnd
  23. EmptyClipboard
  24. SetClipboardData 2, BHandle
  25. CloseClipboard
  26. DeleteDC DestDC
  27. ReleaseDC DHandle, SourceDC
  28. End Sub
  29. '以下的示例把屏幕图象捕捉后,放到Picture1 中。
  30. Sub Command1_Click()
  31. ScrnCap 400, 300, 500, 400
  32. Picture1.Picture = Clipboard.GetData()
  33. End Sub
  34. Private Sub Command2_Click()
  35. ScrnCap 400, 300, 500, 400
  36. Picture2.Picture = Clipboard.GetData()
  37. For i = 1 To Picture1.Width Step 15
  38.     For j = 1 To Picture1.Height Step 15
  39.         If Picture1.Point(i, j) <> Picture2.Point(i, j) Then
  40.             MsgBox "图像改变"
  41.             Exit Sub
  42.         End If
  43.     Next j
  44. Next i
  45. End Sub
复制代码


分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享淘帖0 收藏收藏0 评分评分
您需要登录后才可以回帖 登录 | 立即注册


手机版|SKY外语计算机学习 ( 粤ICP备12031577 )    

GMT+8, 2024-12-22 19:12 , Processed in 0.128995 second(s), 28 queries .

回顶部