Capturing screen shot from webBrowser control in C#
I'm using the webBrowser control and trying to capture a screen shot from it. I start up the webBrowser control and set its URL to some web page. It displays just fine. Then, in response to a button press, I capture the image of the page that's contained within the webBrowser control, like this:
Bitmap bitmap = new Bitmap(webBrowser.Width, webBrowser.Height);
webBrowser.DrawToBitmap(bitmap, new Rectangle(0, 0, webBrowser.Width, webBrowser.Height));
And it does indeed get the page image and I can display it in a pictureBox control.
But a problem occurs when I click on a link in the displayed page and it goes to some other page. If I then click my "grab the page image" button, which again invokes the above code, the image that I get is completely white, even though the page is displayed properly within the webBrowser control.
If I stay on the initial web page I can repeatedly grab the image and display it. But whenever I go to some other subsequent page (which loads into the same webBrowser control) the image that gets grabbed is just plane white.
What do I have to do to get it to get the image from subsequently loaded pages?