如何在不隐藏表单C#的情况下截取屏幕截图

时间:2019-06-06 15:02:54

标签: c# .net winforms

如何在不隐藏表单的情况下截取屏幕截图

我想在截屏时使表格可见...有什么办法做到这一点...

我想捕获隐藏表单的屏幕截图

我希望这不是一件容易的事,但我希望你能帮助我...

请帮助我

2 个答案:

答案 0 :(得分:0)

我不知道后面是什么,但您可以将它们并排放置,就像分屏一样。

如果您在Visual Studio中同时打开了表单和代码,则单击并将其中一个选项卡拖到屏幕上,您将看到一个带有不同屏幕区域的小菜单,只需将选项卡拖到屏幕区域和屏幕上将分裂。 enter image description here

答案 1 :(得分:0)

要捕获屏幕截图,请阅读:Capture the Screen into a Bitmap

在拍摄屏幕快照之前,只需在this.Hide()类中进行Form

截取屏幕截图后,您可以使用Form再次显示this.Show()

示例代码:

this.Hide();
//Create a new bitmap.
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                           Screen.PrimaryScreen.Bounds.Height,
                           PixelFormat.Format32bppArgb);

// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                        Screen.PrimaryScreen.Bounds.Y,
                        0,
                        0,
                        Screen.PrimaryScreen.Bounds.Size,
                        CopyPixelOperation.SourceCopy);

// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);

this.Show();