Salve a tutti. Ho fatto un programma in vb e ho messo un bottone sul quale voglio che si crei lo screenshot SOLO del form e non dell'intero desktop.
Ho questo codice che mi fa lo screen e mi salva l'immagine ma questo prende tutto il desktop e non solo il form come desidero:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Forma…
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 200, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Dim savefiledialog1 As New SaveFileDialog
Try
savefiledialog1.Title = "Save File"
savefiledialog1.FileName = ""
savefiledialog1.Filter = "Bitmap |*.bmp"
If savefiledialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(savefiledialog1.F… System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
'Do Nothing
End Try
End Sub
Come posso fare?
Grazie in anticipo