PC Review


Reply
Thread Tools Rate Thread

capturing WebBrowser screen - .net 2.0

 
 
Jocker
Guest
Posts: n/a
 
      17th Jul 2006
Hi,
I'm trying to get an image of the whole page displayed in the
WebBrowser control (.net 2.0)
OleDraw function should be the way to go.. I've put up the following
code, but it captures only a minimal part of the page (even much
smaller than the visible one) and it stretches it.

[DllImport("ole32.dll")]
internal static extern int OleDraw(IntPtr pUnk, int dwAspect,
IntPtr hdcDraw, ref Rectangle lprcBounds);

private static Bitmap
getBrowserScreenshot(System.Windows.Forms.WebBrowser webBrowser)
{
Rectangle rect = webBrowser.Document.Body.OffsetRectangle;
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics graphics = Graphics.FromImage(bmp);

IntPtr pUnk =
Marshal.GetIUnknownForObject(webBrowser.ActiveXInstance);

IntPtr hdc = graphics.GetHdc();
OleDraw(pUnk, 1 /*DVASPECT_CONTENT*/, hdc, ref rect);
Marshal.Release(pUnk);
graphics.ReleaseHdc(hdc);

return bmp;
}

using the COM object AxWebBrowser there where the method 'GetOcx()'
that returned the activex element behind the control. I believe it is
the same of ActiveXInstance of the .net control.

Any idea on what I'm doing wrong?

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
capturing DOM events in webbrowser control Hari Microsoft C# .NET 1 16th Aug 2007 03:41 PM
Capturing image of a hidden control (webbrowser)... - Electronic.HR - Microsoft C# .NET 1 19th May 2007 10:36 PM
Capturing HTTP requests from WebBrowser 2.0 =?Utf-8?B?TXVyYWQgSXNtYXlpbG92?= Microsoft Dot NET Framework 0 23rd Nov 2006 10:53 AM
capturing the screen rs Microsoft VB .NET 4 27th Jan 2005 05:16 PM
WebBrowser Contro and capturing event ... John Smith Microsoft C# .NET 0 3rd Sep 2003 11:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:13 AM.