我想捕获屏幕但没有当前表单,我尝试最小化 -> 捕获 -> 最大化,但如果存在,我正在寻找更好的解决方案。这是我的代码::
int w = this.Width;
int h = this.Height;
Size sz = this.Size;
Point loc = this.Location;
this.WindowState = FormWindowState.Minimized;
System.Threading.Thread.Sleep(500);
using (Bitmap b = new Bitmap(w, h))
{
using (Graphics g = Graphics.FromImage(b))
{
g.CopyFromScreen(loc, new Point(0, 0), sz);
}
b.Save(Environment.CurrentDirectory + "\\slides\\screen.jpeg");
this.BackgroundImage = System.Drawing.Image.FromFile(@"slides\screen.jpeg");
}
this.WindowState = FormWindowState.Maximized;
我问是否有直接的方法将捕获的图像作为表单背景,而不保存它。