Screenshot? How?? [Resolved]
I have searched through a tons of forums and other sites, but i cannot find any good code to make a screenshot and then save it as a *.jpg file. I know you can convert *.bmp to other formats quite easally with .net. Please, point me in the right direction!
Re: Screenshot? How?? [Resolved]
Wow ...cool
thanks for this thread.
Two Questions:
1. Must you have an picturebox in order for this to work?
2. Can we adapt this so that it can only capture the form which called it?
Cheers!
Re: Screenshot? How?? [Resolved]
If you send the ALT key at the same time, you will only get the form that is in Focus.
ØØ
Re: Screenshot? How?? [Resolved]
This is fully using managed framework code...
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not SaveScreen(Application.StartupPath & "\screen.jpg") Then
MessageBox.Show("Sorry dude, couldn't do it.")
End If
End Sub
Public Function SaveScreen(ByVal theFile As String) As Boolean
Try
SendKeys.Send("%{PRTSC}") '<alt + printscreen>
Application.DoEvents()
Dim data As IDataObject
data = Clipboard.GetDataObject()
Dim bmp As Bitmap
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmp = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
bmp.Save(theFile, Imaging.ImageFormat.Jpeg)
End If
Clipboard.SetDataObject(0) 'save memory by removing the image from the clipboard
Return True
Catch ex As Exception
Return False
End Try
End Function
Re: Screenshot? How?? [Resolved]
Sorry to dig up an old thread, but is it possible to get a screenshot of a MDI Child form? instead of the whole form?
Re: Screenshot? How?? [Resolved]
I posted a thread about Blitting in the codebank a few months ago, the class therein contains a screengrab() function that you can pass the rectangle of yuor form into.