Sorry if the title is confusing, I'm not sure how to word it.
I have a transparent panel on my form. I want to be able to move the form around, and then click a button and have it take a screenshot of what you see through the transparent panel.
The problem is that it's only taking screenshots of the area of the screen where the panel would be if the form were located at 0,0 on the screen. Here's a picture to illustrate the problem.
Attachment 92651
As you can see in this image. Imagine that the form was located at 0,0. The panel would be located where the green box is. When I take a screenshot from "where the panel is located", i receive a screen shot of what's in the red box... when I want to get a screenshot of what you see in the transparent panel.
This is my code:
How could I correctly have it target the exact location of the panel?
I have a transparent panel on my form. I want to be able to move the form around, and then click a button and have it take a screenshot of what you see through the transparent panel.
The problem is that it's only taking screenshots of the area of the screen where the panel would be if the form were located at 0,0 on the screen. Here's a picture to illustrate the problem.
Attachment 92651
As you can see in this image. Imagine that the form was located at 0,0. The panel would be located where the green box is. When I take a screenshot from "where the panel is located", i receive a screen shot of what's in the red box... when I want to get a screenshot of what you see in the transparent panel.
This is my code:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bmpScreenShot = New Bitmap(Panel1.Bounds.Width, Panel1.Bounds.Height, PixelFormat.Format32bppArgb)
Dim boxSize As New Size(200, 85)
gfxScreenshot = Graphics.FromImage(bmpScreenShot)
gfxScreenshot.CopyFromScreen(Panel1.Bounds.X, Panel1.Bounds.Y, 0, 0, boxSize, CopyPixelOperation.SourceCopy)
PictureBox1.Image = bmpScreenShot
End Sub