Hello group,
I have a project with several WebBrowser objects on separate tabs. I
want to take screenshots of these. I am currently using the
PrintWindow function. (Code below.) This works if the tab is open and
the WebBrowser is displayed. For browsers on other tabs, however, the
resulting bitmap is black.
Any ideas on how to tweak this code so that it snapshots WebBrowsers
on tabs that are not selected? Or should I be using a different method
altogether?
Thank you,
J Wolfgang Goerlich
The C# code ...
[DllImport("user32.dll")]
private static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt,
uint nFlags);
private void BrowserSnapShot(System.Windows.Forms.WebBrowser
targetBrowser)
{
// Get the image width and height
int screenWidth = targetBrowser.Width;
int screenHeight = targetBrowser.Height;
// Create the output
// HWND hwnd, Window to copy
// HDC hdcBlt, HDC to print into
// UINT nFlags, Optional flags
// Set hwnd to the WebBrowser
IntPtr myIntptr = targetBrowser.Handle;
int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
// Set hdc to the bitmap
Bitmap bm = new Bitmap(screenWidth, screenHeight,
System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);
Graphics g = Graphics.FromImage(bm);
IntPtr hdc = g.GetHdc();
// Snapshot the WebBrowser
bool result = PrintWindow(hwnd, hdc, 0);
g.ReleaseHdc(hdc);
g.Flush();
// Save the bitmap, if successful
if (result == true)
bm.Save("C:\\Inetpub\\wwwroot\\slide.bmp");
} 4 12459
On Feb 20, 9:20 pm, jwgoerl...@gmail.com wrote:
Hello group,
I have a project with several WebBrowser objects on separate tabs. I
want to take screenshots of these. I am currently using the
PrintWindow function. (Code below.) This works if the tab is open and
the WebBrowser is displayed. For browsers on other tabs, however, the
resulting bitmap is black.
Any ideas on how to tweak this code so that it snapshots WebBrowsers
on tabs that are not selected? Or should I be using a different method
altogether?
Did you try to use WebBrowser.DrawToBitmap()?
As far as I know it does the same and you can use it for all your
WebBrowser objects in the same time
Did you try to use WebBrowser.DrawToBitmap()?
Is there something special needed to enable this? Visual Studio 2005
reports that "this method is not supported by this control."
J Wolfgang Goerlich
On Feb 20, 11:12 pm, jwgoerl...@gmail.com wrote:
Did you try to use WebBrowser.DrawToBitmap()?
Is there something special needed to enable this? Visual Studio 2005
reports that "this method is not supported by this control."
J Wolfgang Goerlich
F1 :-)
Namespace: System.Windows.Forms
I found that you use C:\\Inetpub\\wwwroot\\
Does it mean you do it in ASP.NET? If yes, take a look this tip at http://www.codeproject.com/useritems...screenshot.asp
F1 :-)
Good ol' help. Though not supported, it does work just as detailed in
the ASP.NET article (thanks!).
"DrawToBitmap - This method is not supported by this control.
(inherited from WebBrowserBase)" http://msdn2.microsoft.com/en-us/lib...r_members.aspx
And yet, the DrawToBitmap acts the same as the PrintWindow. It creates
a good snapshot if the tab with the WebBrowser is selected. It creates
a black, blank bitmap if the tab is not selected. Looks like I may
have to settle for selecting the tab with the WebBrowser, creating the
bitmap, and then going back to the originally selected tab.
J Wolfgang Goerlich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: SPE - Stani's Python Editor |
last post by:
Hi,
During optimizing SPE for Ubuntu, I found something strange. I have
Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not
working:
>>> import webbrowser
>>>...
|
by: Li-fan Chen |
last post by:
Hi,
In creating an email client, we are trying to allow users to pick and choose
their email templates and photo stocks. We thought it'd be very 2006 to show
a gallery of thumbnails. Is this a...
|
by: Alex Clark |
last post by:
Greetings,
(.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs).
I've decided to take advantage of the layout characteristics of HTML
documents to simplify my printing tasks, but...
|
by: dananrg |
last post by:
Is there a Python module that, given a URL, will grab a screenshot of
the web page it goes to? I'd like to be able to feed such a module a
list of URLs from a file.
Thanks very much.
|
by: Anil Gupte |
last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot
figure out where it is in .Net
Thanx,
--
Anil Gupte
www.keeninc.net
www.icinema.com
|
by: mareeus |
last post by:
Hi,
Are there any ways I could get a screenshot of a web-page at a
specific address in jpeg via php script?
Regards,
Marius.
|
by: phpfreak2007 |
last post by:
Hello,
I want screenshot of website by passing url. I used the DrawtoBitmap method of webbrowser but it is not working properly. It gives empty images. I want screenshot of websites which i...
|
by: kimiraikkonen |
last post by:
Hi there,
I needed to use MouseOver event on Webbrowser which is NOT provided by
webbrowser control natively(what a disappointment), so i decided to go
with another route to simulate this like:
...
|
by: TedTrippin |
last post by:
Hi,
Background - I've create a windows application in VS and added a WebBrowser component and all works well.
I'm now trying to do this programmatically. My application now listens on a socket...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |