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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...