I'm using a webBrowser control. After it is finished loading, I want to be able to determine what portion of the browser actually contains controls. For example, let's say the web page has a <CENTER> tag that centers the entire page within the browser. I'd like to be able to find out what the X coordinate is of the left side of the left-most displayed object, as well as the X coordinate of the right side of the right-most displayed object.

My reason for needing this information is that I want to take a "snapshot" image of the displayed page but have it include only the actual displayed parts of the page. I don't want to capture the whole browser image, just the portion of it that includes the actual page. I am able to grab a snapshot of it (using bitmap/Image operations) but I'd really like to be able to grab just the "important" parts.

So, is there any way to determine the left-most and right-most object positions?

Recommended Answers

All 3 Replies

You can do this without code if it's for personal use, however if you want the app you're developing to do this then I can't help. To do it without code, press CTRL + ALT + PrtSc with the browser on whatever page you need to capture an image of. Now go open the Paint application in your accessories folder on the start bar. Now just press CTRL + V then select the area you want finally press crop. That simple. :D

Like I said, with code, I can't help you. Sorry. :(

This needs to be done from code. I know how to grab the image of the displayed page from the Microsoft C# webBrowser control, and I can conceivably grab any portion of the image that I want, but what I need is to know exactly which portion of that image actually contains the displayed page. It's possible that a displayed page may be left-justified or centered. It's possible that the displayed page might extend 800 pixels to the right, or 1065 pixels to the right. Or, if centered, be between pixel # 104 on the left and 1403 on the right. It's those "page extent" numbers that I'd like to be able to get. Certainly the code inside the webBrowser that renders the page knows where it's putting the data into the image. What I need is some way of retrieving that info from the webBrowser.

And it's got me baffled.

I don't see that they expose anything that will give you this information (or any information about the rendered size).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.