Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen capture and the Web Browser control 3

Status
Not open for further replies.

mmilan

Programmer
Jan 22, 2002
839
GB
I could use some help with this one, because if we can't solve the issue, there's a good chance that I am going to be nominated to go and talk my poor depressed colleague down from the roof!

Basically, we need to capture the contents of the webbrowser control as a bitmap - though we'll settle for any other graphical format...

The tricky bit it that we need the entire contents of the control, and not just the bit the control is choosing to show at that moment (ie no scrolling...).

The reason we need this is to pass a bitmap to a faxing program, the bitmap being the graphical representation of the output of some XML...

Cheers in advance for any help!
 

Why can't you print from the WB to the faxing program??? Or to a fax driver??? Or to a tiff driver???

 
First of all, I'm not the programmer undertaking the project - merely one of his colleagues...

The poor unfortunate (Phil) has to use a faxing program that our company has created, based on the FaxMan control. That might not be terribly sensible, but it's a directive passed down from the lofty heights of management, so we're stuck with it...

Any ideas on how to capture the entire window?
 

If the program has been set up like a print driver you could print right to it. If not then look into say a tiff driver that you can print to. One of them that I know of is peernet (.com i think).

Good Luck

 
I'll pass that on.

No ideas about capturing the window though?

Many thanks,

Martin
 

Only problem capturing the window is it will capture (if I remember correctly) only the visible portion. I know there is code around that will capture the desktop and save it out as a bit map and if I also remember correctly it takes an arguement of the hwnd. It may work if you pass in the hwnd of the window that contains the webbrowser control if not the webbrowser control itself.

Good Luck

 
I use Snagit, a nifty utility that creats a bitmap of everything you put a rectangle around like the cut and paste in Paintbox. It runs in the background and has a hot key to activate.(Ctrl Shft P)
It pastes directly to the clipboard
You can easily get the image straight out of the clipboard with VB or save it to a file.
Saves reinventing the wheel!
 
The problem here, mmilan, is that the window in which the web page appears in the browser is a just a rendering area. In other words, the only part of the web page that is actually rendered is the bit that is visible in the browser. When you 'scroll' what actually happens is that the image is blitted up or down, and a custom paint routine then fills in the newly exposed blank area from data hidden away somewhere in the web browser's memory. What this means is that there is no way of directly capturing the 'whole' window (whereby we mean the entire web page), since no such window exists (unless, of course, the page happens to be small enough to fit in the visible area). The only bit you can directly capture is the visible bit

I may have explained this badly, so here is an example that might help to illustrate the problem. Start a new Project and add a Textbox. Make the Textbox multiline, and make it high enough to show 2 lines of text. Add a VScroll. The copy and paste in the following code:
[tt]
Option Explicit

Private Sub Form_Load()
VScroll1.Max = 9
VScroll1_Change
End Sub

Private Sub VScroll1_Change()
Text1.Text = VScroll1.Value & vbCrLf & VScroll1.Value + 1
End Sub
[tt]
Ok, when you use this program, it gives the appearance of a window containing the numers 0 to 10, of which only 2 numbers are visible at one time. But actually all you have got is a window that displays 2 digits depending on the scroll position. There is no way you could actually capture a whole window containing all the digits because at no time does such a window exist.

Right, so the 'capture the wole window' approach is stuffed, so what can we do?

Well, the FaxMan product comes with the necessary print drivers for directly creating and sending fax files from any application with a Print option. I'd suggest you (or your colleague) seriously consider the advice given by vb5prgrmr about using this printer driver.
 
Cheers strongm...

It looks like it's a good day not to be Phil... Stars all round I feel!

mmilan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top