乐博网有载了一篇关于api抓屏的实例,本次载的是老外Jason Hensley写的抓屏,实现方式与上次不同,可以方便大家对比
''开发平台 VB.NET 2005 <Beta 2>VB.NET抓屏的另一实例
''Description: A basic example of using the new built-in Sub in the '2.0 version of the dotNetFramework to capture the screen, or portion 'of the screen and putting the image in a picturebox. Then you have 'the option of saving the picturebox image to a JPEG file. This example 'just uses the basic SourceCopy raster on the screenshot. There 'are many raster-operations you can choose from. ''Update: Reworked the code to be compatible for VB.NET <Beta 2>. I Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click 'Create the bitmap
Dim s As Size = New Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height) 'See whether or not to hide the program before taking the Me.Hide() 'Clear this variable from memory. Else 'Copy the image from the screen. You can customize the size End If 'Load the copied image to the picturebox control. 'Clean up alittle. End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim saveDlg As SaveFileDialog = New SaveFileDialog 'Set the filter to JPEG files only. dlgResult = saveDlg.ShowDialog If dlgResult = Windows.Forms.DialogResult.OK Then 'Save the image contained in the picturebox. End If End Sub VB.NET抓屏的另一实例End Class |