PrintWindow导致窗口闪烁

时间:2012-04-24 20:37:46

标签: c# screenshot

我的C#app需要能够捕获特定窗口的位图,无论该窗口是否位于顶部。我用PrintWindow做这个(感谢其他stackoverflow答案),它基本上就是这样......

...
[DllImport("user32.dll")]
public static extern bool PrintWindow(IntPtr hWnd, IntPtr hdcBlt, int nFlags); 
....
Bitmap thisScreenshot = new Bitmap(Width, Height);
Graphics gfxScreenshot = Graphics.FromImage(thisScreenshot);
IntPtr hdcBitmap = gfxScreenshot.GetHdc();
PrintWindow(stickyProgHandle, hdcBitmap, 0);
gfxScreenshot.ReleaseHdc(hdcBitmap);
...

我现在唯一的问题是,每次调用PrintWindow时,我正在捕获的窗口会闪烁(就像刷新该窗口一样)。假设PrintWindow是我最好的选择,我怎么能摆脱闪烁?

UPDATE1:请注意,闪烁是在我抓住屏幕截图的窗口中,而不是我的应用程序窗口。

0 个答案:

没有答案