问题
I am trying to take a screenshot with a form of a screen BUT I don't want my form to be included in the screenshot. This is my current Code for getting the screenshot.
Bitmap bt;
Graphics screenshot;
private void button1_Click_1(object sender, EventArgs e)
{
this.Opacity = 0;
bt = new Bitmap(Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height, PixelFormat.Format32bppArgb);
screenshot = Graphics.FromImage(bt);
screenshot.CopyFromScreen(Screen.FromControl(this).Bounds.X, Screen.FromControl(this).Bounds.Y, 0, 0, Screen.FromControl(this).Bounds.Size, CopyPixelOperation.SourceCopy);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = bt;
this.Opacity = 1;
}
This works to a degree, but the problem is that when I do this it causes the screen to flicker each time. Is there any way to make it so it doesn't include my form, but still takes everything behind it?
回答1:
You cannot take a screenshot of what is behind your form, but you can hide you form, take a screen shot and show your form again. How to do this:
- Hide your form
- Wait some time until the screen has been repainted.
- Take the screenshot.
- Show your form.
You should make 2 asynchronous by using a Timer class.
Good luck with your task.
来源:https://stackoverflow.com/questions/16740083/take-screenshot-of-screen-behind-form