这是我的代码:
私人无效按钮1_Click(对象发送者,EventArgs e) { for (int i = 1; i < Application.OpenForms.Count; i++) { if (Application.OpenForms[i].WindowState == FormWindowState.Minimized) {
Application.OpenForms[i].WindowState = FormWindowState.Normal; using (var bmp = new Bitmap(Application.OpenForms[i].Width, Application.OpenForms[i].Height)) { Application.OpenForms[i].DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height)); bmp.Save(@"d:\Duong\" + Application.OpenForms[i].Text + ".png"); } Application.OpenForms[i].WindowState = FormWindowState.Minimized; } else { using (var bmp = new Bitmap(Application.OpenForms[i].Width, Application.OpenForms[i].Height)) { Application.OpenForms[i].DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height)); bmp.Save(@"d:\Duong\" + Application.OpenForms[i].Text + ".png"); } } } }
每个 Application.OpenForms[i] 都有一个 MdiParent。当其中一些被最小化,一些被激活时,我点击一个按钮来获取快照,我得到了每个表单的所有图片。但是任何最小化的表单在返回最小化之前都会出现闪烁。我知道问题来自 WindowState,但是如果它不显示,我该如何获取快照?..请帮助我..我已经看到有关 API GDI+ 的主题..但它们是用于最小化窗口应用程序的,我现在只需要我的表格和它的孩子。谢谢