问题
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