问题
I have a windows form application.
The form is large & has scroll bars to view its entire content.
I need to take the screen shot of the entire form(including the area which is outside of screen due to the forms height).
I tried following code, but it captures only the part of the form which is visible on screen:
ScreenCapture sc = new ScreenCapture();
// capture entire screen, and save it to a file
Image img = sc.CaptureScreen();
// display image in a Picture control named imageDisplay
this.imageDisplay.Image = img;
// capture this window, and save it
sc.CaptureWindowToFile(this.Handle,"C:\\temp2.gif",ImageFormat.Gif);
I am not able to take screen shot of the entire Form.
Can anybody please let me know the way to capture the entire form including the area which is hidden due to scroll?
回答1:
Consider drawing the screen to a bitmap: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
There are some limitations though, the maximum size might be constrained and drawing a rich text box does not work.
回答2:
Did you try using Control.DrawToBitmap you can use it on the form as well as specific controls in the form.
来源:https://stackoverflow.com/questions/19964834/how-to-take-screen-shot-of-windows-form-with-scroll-bar-in-c-sharp