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:
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?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Zoran HorvatRank #792 · 2.9K reputationPosted Dec 13, 2010, 4:33 AM EST
0
You can cast WebBrowser control to Control class and then use it's DrawToBitmap method. However, DrawToBitmap is not really supported by WebBrowser class - often it simply draws blank picture and nothing else. WebBrowser class has changed access modifier of this method in order to prevent users from calling it.
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.
Zoran HorvatRank #792 · 2.9K reputationPosted Dec 13, 2010, 4:33 AM EST
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.