微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VB.NET屏幕截图方法2则

【搬运】VB.NET屏幕截图方法2则

    
    
' 根据VB6代码改的,经过本人优化。请先导入Drawing类库。
Declare Function SelectObject Lib " gdi32 " ( ByVal hdc As Integer , hObject ) BitBlt hDestDC x y nWidth nHeight hSrcDC xSrc ySrc dwRop CreateCompatibleBitmap CreateDC Alias CreateDCA lpDriverName String lpDeviceName lpOutput ByRef lpInitData CreateCompatibleDC
GetSerPic(
Optional BitWidth = - 1 BitHeight Image
If
< 0 Then My.Computer.Screen.Bounds.Width
My.Computer.Screen.Bounds.Height
Dim
Bhandle,DestDC,SourceDC IntPtr
SourceDC
CreateDC( disPLAY nothing )
DestDC
CreateCompatibleDC(SourceDC)
Bhandle
CreateCompatibleBitmap(SourceDC,BitWidth,BitHeight)
SelectObject(DestDC,Bhandle)
BitBlt(DestDC,BitHeight,SourceDC,0); font-family:'Courier New'!important; line-height:1.5!important">&
HCC0020)
Return
Image.FromHbitmap(Bhandle)
End Function

最近学了Graphics类的画图方法,所以无聊就写了两个小程序' 这一例是不使用系统API就可以进行屏幕截取代码 Public Class frmMain
Private Sub Button1_Click( sender System.Object,0); font-family:'Courier New'!important; line-height:1.5!important"> e System.EventArgs) Handles Button1.Click
Me
.Hide()
p1
New Point( p2 Point(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height)
pic
Bitmap(p2.X,p2.Y)
Using
g Graphics Graphics.FromImage(pic)
g.copyFromScreen(p1,p1,p2)
.BackgroundImage
pic
End
.Show()
End Sub
End Class

原文地址:https://www.jb51.cc/vb/258282.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐