How to take a screenshot of a Full Size window in C#

蹲街弑〆低调 提交于 2019-11-28 11:47:56

You're making an assumption here that's not necessarily true: that there's something there already waiting in the unscrolled area. An application can build scroll bars for a certain height or width and not actually render anything to the surface until the user actual drags the scroll bar. The image you want to capture exists only in potential. This can be used to improve performance — think just-in-time loading, or reducing memory use. It's a fairly common technique, and so what you're asking for doesn't really make sense.

Capture screen contents without using any Win32 API calls, just using .NET 2.0 at CodeProject.

If you're trying to get content that's offscreen, then WM_PRINT may work. BitBlt assuredly will not.

See:

You would need to redraw the whole window/form onto a graphics object. A (simple) example of how this can be done can be found in this CodeProject article. You'd need to implement support for all controls that you need in your project. Also, if you resize the window in the example application (obscure some controls) and make a test print, you'll see that the main form, which is just another control, is drawn over the other controls, which is no real problem but doesn't look very good - you could just remove support for drawing the main form if thats an issue.

Alternatively, if using or switching to WPF, you can print controls (including the main window) by using PrintDialog.PrintVisual().

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