Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42461

VS 2010 How can I properly take a screenshot of what's in a specific panel?

$
0
0
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:
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

How could I correctly have it target the exact location of the panel?
Attached Images
 

Viewing all articles
Browse latest Browse all 42461

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>