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

后端 未结 4 1416
感动是毒
感动是毒 2020-12-10 22:51

I am trying to create an application in C#.net that captures the screenshot of the current active window including the area that has to be scrolled using scroll bars.I found

相关标签:
4条回答
  • 2020-12-10 23:41

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

    0 讨论(0)
  • 2020-12-10 23:48

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

    See:

    • MSDN description of WM_PRINT
    • Window Contents Capturing using WM_PRINT Message
    0 讨论(0)
  • 2020-12-10 23:50

    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.

    0 讨论(0)
  • 2020-12-10 23:50

    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().

    0 讨论(0)
提交回复
热议问题