473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

capturing WebBrowser screen - .net 2.0

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

Jul 17 '06 #1
0 1789

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: joseph.inglis | last post by:
Heres an interesting one and i guess its idea that are needed as opposed to a direct solution (although one would be welcomed of course). I want to render a webpage as an image. At the moment...
2
by: Carsten Klotz | last post by:
Hi, does someone know, if it's possible capturing the content of a panel, when its form has state "minimized"? Details: A panel contains a Webbrowser object (AxSHDocVw.AxWebBrowser). My...
8
by: rs | last post by:
Hi guys, How can I capture a window or the whole screen and save it as a picture? Thanks Ahmed
2
by: Slack | last post by:
I wish to write a console text editor. Can anyone tell me how to capture the screen like Vi or Pico does? Also, I wish to draw "tabs" on the screen, is there a standard way to draw so that my...
0
by: te.richardson | last post by:
I want to write a screensaver that plays powerpoint presentations. So I have a form with a webbrowser control. Is there any way to get the containing form to know when the user has moved the mouse...
2
by: smalltownworld | last post by:
Anyone got an idea of capturing a screen without api and or opengl/directx? Was thinking about reading from primary display driver memory but not sure if it can be parsed into an image . . . Any...
1
by: kencana | last post by:
hi all, is that possible to capture the screen size of the mobile and use the captured screen size to resizing the image.so that, the image will be displayed fixed to the screen size. if...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.