| ||||||||||||||||||||
| ||||||||||||||||||||
Note:
This is an unedited contribution. If this article is inappropriate, needs
attention or copies someone else's work without reference then please Report
This Article
IntroductionThe SCapture class allows an application to capture a still screen image. It also provides a functionality to include the cursor in the image. Class shared methods
BackgroundThe class differs from some other similar articles that provide classes to capture an image from the screen by giving the application ability to capture transparent windows images. The core of the class is based on some Api methods. Using the codeA small example to capture a button control image from a form by using a point on the button. Private Sub ControlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ControlButton.Click
Try
'Capture the image of this button including the cursor.
Dim img As Image = SCapture.Control(Control.MousePosition, True)
'Save the captured image.
img.Save(filePath, Drawing.Imaging.ImageFormat.Png)
'Also dispay the captured image on a PictureBox.
Me.DisplayPictureBox.BackgroundImage = img
Catch ex As Exception
'Show a MessageBox if the capture of image failed.
MessageBox.Show("Failed to capture the control!" _
& Environment.NewLine & ex.Message, "Capture Error!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
HistoryOriginally posted on 07/21/08 Discussions and Feedback
| ||||||||||||||||||||