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