I had made a example for test with two buttons:
Button1 => capture screen and save it to a MemoryStream
Buton2 => Shows "Form2" maximized already with the image captured defined on a PictureBox present on other Form.
And it works very fine!
The trouble now is that, I'm trying make it in my Remote Administration Tool and when I go show the "Form2" he crashes, and after stop work.
Here is my code until now:
Code:
Case "Lock" 'first capture screen
img = cap.TakeScreenShot 'captures screen
memory = New MemoryStream
img.Save(memory, System.Drawing.Imaging.ImageFormat.Jpeg) 'save it to memory
Case "Jump" 'after show this captures on another Form
Dim tr As New Thread(Sub()
locker.Screenshot.Image = Image.FromStream(memory)
locker.Screenshot.Image = cap.ChangeOpacity(Image.FromStream(memory), 0.3)
locker.Show() 'rises other Form (mamimized) already with screen captured into PictureBox
memory.Dispose() 'release MemoryStream
img.Dispose() 'release Bitmap
locker.Screenshot.Dispose() 'release PicturBox on other Form
End Sub)
tr.Start()
tr.Join()
And here is my example that works very fine:
Code:
Dim img As Image
Dim memory As MemoryStream
Public Function TakeScreenShot() As Bitmap
Dim screenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim g As Graphics = Graphics.FromImage(screenGrab)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)
Return screenGrab
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
img = TakeScreenShot()
memory = New MemoryStream
img.Save(memory, System.Drawing.Imaging.ImageFormat.Gif)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form2.PictureBox1.Image = Image.FromStream(memory)
Form2.Show()
memory.Dispose()
img.Dispose()
End Sub
So, someone can helpe me to solve it please?
Any suggestion will welcome.
Thanks in advance.