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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from the _webview foundation class

Status
Not open for further replies.

GlenGodbold

Programmer
Mar 5, 2001
14
GB
We're using the _webview web browser to display htm pages in an application. Does anyone know if is possible (and if so how) to print the displayed page

Thanks for any suggestions

Glen Godbold
HWA
 
According to the MSDN library:


Printing Pages with the WebBrowser Control
Although the WebBrowser control does not support a print method, you can print its contents by using one of the following methods:

Set the focus to the WebBrowser control and send a key combination of CTRL+P.
Call the IWebBrowser2::get_Document method, as shown in this example.
(Note: example is in C++)

So, you should be able to at least get a workaround with code like this:
Code:
oMyWebBrowser.SetFocus()
KEYBOARD "{CTRL+P}"
Hope that helps...

Ian
 
Hi Ian

Thanks

That sort of works - if I set the focus to the browser (either by program or by clicking on the control) then pressing control+p on the keyboard prints the page fine, but I can't get the keyboard '{CTRL+P}' command to work either in a button with the following in the click event

oWeb.setfocus()
KEYBOARD '{CTRL+P}'

(I've tried adding plain and/or clear)

or by putting the keyboard command in the gotfocus event of the browser

Do I need to do something to get it out of the keyboard buffer??

Glen
 
Try adding a DOEVENTS line:
[tt]
oWeb.setfocus()
DOEVENTS
KEYBOARD '{CTRL+P}'
[/tt]
This will wait to stuff the keystroke until AFTER the focus is set.

Other than that I'm afraid I have no idea. :eek:(

Ian
 
Hi Ian

Again thanks, but still doesn't work.

However a colleague has found the following Q265126 on the July 2001 MSDN disk

#DEFINE OLECMDID_PRINT 6
#OLECMDEXECOPT_PROMPTUSER 1
#OLECMDEXECOPT_DONTPROMPTUSER 2
oWeb.ExecWB(OLECMDIDPRINT, OLECMDEXECOPT_DONTPRMPTUSER)

Which works fine. Thanks for your help

Glen
HWA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top