C# Using PrintWindow

∥☆過路亽.° 提交于 2019-12-13 09:13:20

问题


I am trying to capture a window in win7 without disabling aero and I hear PrintWindow Works.

But I'm not sure how to use it, I found some articles but I can't see any image or bitmap output in any of them

Has anyone ever had experience with this function and knows how to use it?


回答1:


Previous link here.

Code sample from the same link:

Graphics g = form.CreateGraphics();
Bitmap bmp = new Bitmap(form.Size.Width, form.Size.Height, g);
Graphics memoryGraphics = Graphics.FromImage(bmp);
IntPtr dc = memoryGraphics.GetHdc();
bool success = PrintWindow(form.Handle, dc, 0);
memoryGraphics.ReleaseHdc(dc);
// bmp now contains the screenshot

Also as specified in the above link you can use managed Control.DrawToBitamp to achieve the same thing.



来源:https://stackoverflow.com/questions/6409168/c-sharp-using-printwindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!