加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

VB.NET屏幕截图方法2则

发布时间:2020-12-17 08:03:35 所属栏目:百科 来源:网络整理
导读:【搬运】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 CreateCompatibleBi

【搬运】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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读