Ok, playing around with a small project in C# were I have a tabed control and each tab has it's own web browser control in it. The idea is to be able to switch between different web pages. The thing is that on one of the pages (located in the first tab) is constantly updating so I need a way to see what is going on even if I am in an other tab.
So I thought I would make a small image of the site that is displayed on the right side of the form. It works just like the live images you see of a web browser in the windows task bar when you hoover it's icon with the mouse.
What I did was that I added a timer control and in it's tick event I added the following:
Bitmap bm = new Bitmap(webBrowser1.ClientRectangle.Width,webBrowser1.ClientRectangle.Height);
Graphics gr = Graphics.FromImage(bm);
gr.CopyFromScreen(webBrowser1.PointToScreen(new Point(0,0)), new Point(0,0), new Size(webBrowser1.Width,webBrowser1.Height));
pictureBox1.Image = bm;
|
Works great but as I point out only the points from were to read the image I will always show the image of the web browser that is in the active tab and not the one in the first tab.
How do I work around this?
Zoran HorvatPosted Dec 13, 2010, 9:33 AM
I think there is no way to properly make a snapshot of a WebBrowser control which is not currently visible.
There are two ways out as I see this situation:
1. Find a different control which supports rendering to bitmap, or
2. Whenever required to draw the WebBrowser which is not visible, create another form, move the browser onto that form, show the form outside bounds of the screen and then create screenshot of that area; after doing that, return browser to its original place.
I haven't tried any of these two solutions.