Screen Caputre code not working
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
Hello well basically i want to take a screen print of a panel and its contents and apply this to a picturebox after searching the web i have built this out of code i learnt from the web but well my edit seems to have messed things up it takes a picutre of were the panel was on form load but does not take it when the form moves or of the hole panel only a small cornoer of it
So here is the code i am using
So here is the code i am using
Code: Select all
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim b As Bitmap
b = New Bitmap(Panel3.Width, Panel3.Height, Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(b)
g.CopyFromScreen(Panel3.Location, Panel3.Location, New Size(Panel3.Width, Panel3.Height))
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.Image = b
End Sub
It would be more reliable to use Panel.DrawToBitmap rather than Graphics.CopyFromScreen. In that code Panel3.Location is not a relative position for the screenshot.
basically i want to take a screen print of a panel and its contentsYou can use this:
Code: Select all
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim b As Bitmap = New Bitmap(Panel3.Width, Panel3.Height, Imaging.PixelFormat.Format32bppArgb)
Panel3.DrawToBitmap(b, New Rectangle(New Point(0, 0), b.Size))
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.Image = b
End Sub
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023