Results 1 to 7 of 7

Thread: *** RESOLVED *** Disable Print in WebBrowser control

Threaded View

  1. #1

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Resolved *** RESOLVED *** Disable Print in WebBrowser control

    I have been trying to figure out how to disable print functionality in the WebBrowser control.

    Just a note - I am very new to C#. I have pretty heavy experience in VB6 and Java though.

    Some pages I will be loading have javascript in them that brings up the print dialog. This application is simply "scraping" the page contents and moving on to the next page in the list the user entered. When the print dialog displays, the app waits for the user response and does not continue to the next page. In addition, if the user enters 10,000 pages to navigate, I don't want them to have to click cancel on all 10,000, should each one call print through javascript.

    Code:
    <script language="JavaScript">
    window.print();
    </script>
    I have tried just about everything I can think of without any luck.

    What I have tried:
    1. Extending the WebBrowser control and overriding the print() method. The print method can not be overloaded according to my compiler...

    2. Using an older version of the WebBrowser control and setting the Silent property to true.

    3. Stripping the print() method from the page before it gets to the browser via the navigating/navigated events. The problem with this is that some pages/parts of pages could be refreshed via AJAX so these events will not fire.

    4. Disabling internet printing via the registry. This pops up a dialog saying that the action can not be taken. This popup poses the same problem as popping up the print dialog.

    5. Disabling javascript is not an option as some pages use AJAX and require the javascript to work properly.


    What remains to be tried (but I don't really know how):
    1. Using a hook to catch the print dialog and cancel/close it.

    2. Use a timer to look for the print dialog, via api, every XX milliseconds and close it when it is found.

    3. ???


    I don't know how to use the API in C# (although I am sure I could find plenty of documentation on it), so I have not tried anything with it yet.

    Any suggestions?

    Thanks in advance.
    Last edited by finn0013; Aug 11th, 2006 at 03:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width