Me.Controls.Add(Me.Button1) Me.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(255, Byte), CType(255, Byte)) Me.Name = "Form1" Me.Text = "wgscd" Me.ResumeLayout(False) End Sub #End Region
’VB.NET中进行图象捕获 ,需要先引用一些API,以下是声明: Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer Const SRCCOPY As Integer = &HCC0020 ’将以下代码添加到Button1_Click事件中:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hDC, hMDC As Integer Dim hBMP, hBMPOld As Integer Dim sw, sh As Integer hDC = GetDC(0) |