How to take screen shot of Windows Form with Scroll Bar in c#

拥有回忆 提交于 2019-12-13 02:01:17

问题


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

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