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

Print web browser control within vb.net form

Status
Not open for further replies.

Kenny62

Programmer
Mar 3, 2004
54
GB
Hi - i'm trying to printing the contents of a web browser control. Users want the prompt dialog displayed before printing.

I done something like this:

AxWebBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, 0, 0)

If i on clicking the cancel button on this dialog i get a runtime error with the following call stack:

Trying to revoke a drop target that has not been registered
Original Source::Interop.SHDocVw
at SHDocVw.IWebBrowser2.ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, Object& pvaIn, Object& pvaOut)
at AxSHDocVw.AxWebBrowser.ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, Object& pvaIn, Object& pvaOut)
at wfm.frmInfo2.btnPrint_Click(Object sender, EventArgs e) in ...

Does anyone know why this error occurs and how do i fix it.

(If i use OLECMDEXECOPT_DONTPROMPTUSER in code - there are no errors - the print dialog is not displayed. I have looked at previous post ...)

Thanks for any help in advanced, Ken


 
AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

I use this and it works fine.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks for the suggestion - i now get a diffent runtime error:
Exception has been thrown by the target of an invocation.
Original Source::mscorlib
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Reflection.MethodInfo.Invoke(Object obj, Object[] parameters)
at AxSHDocVw.AxWebBrowser.ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt)
at wfm.frmInfo2.btnPrint_Click(Object sender, EventArgs e) in

Any idea - this happens when i click the cancel button on the print dialog

Thanks for any help in advanced, Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top