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.WebBrows er 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.ActiveXIns tance);
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