Ask a questionAsk a question
 

QuestionIE8 Printing problem

  • Tuesday, September 29, 2009 12:52 PMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    In our code (C++, MFC) we use MS ActiveX control HTML View for printing - We use ExecWB function with OLECMDID_PRINT option. When we pass MSOCMDEXECOPT_DONTPROMPTUSER parameter to the function everything is OK. When we pass MSOCMDEXECOPT_PROMPTUSER, the Print Setup dialog pops up and we get an error: "Internet Explorer script error" - Error: Permission denied, URL: res://ieframe.dll/preview.js
    What is a problem?
    IE7 works fine.
    Thanks

All Replies

  • Thursday, October 01, 2009 3:37 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    I see many similar reports of the issue in the forum:
    http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/bc7a73df-d4e0-4292-83e4-80d58fc765af/
    but I do not seem to be able to reproduce it in my lab. Could you please help me see the problem?

    Here is my attempt:

    In VS2008 (SP1), I created a MFC dialog project, and insert the Microsoft Web Browser control to the dialog. In the code behind, I navigate the webbrowser control to www.bing.com:

     COleVariant var(L"http://www.bing.com");
     this->m_explorer.Navigate2(var, NULL, NULL, NULL, NULL);

    After the page is loaded, I issue the OLECMDID_PRINT command:

     this->m_explorer.ExecWB(OLECMDID_PRINT, MSOCMDEXECOPT_PROMPTUSER, NULL, NULL);

    The print dialog is displayed without errors.

    I tested this on Windows 7 + IE8, and Windows Vista + IE8.

    Regards,
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Thursday, October 01, 2009 9:47 AMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Jialiang Ge,

    Thank you for you reply.
    We reproduce the problem on WinXP + IE8. The MS Web Browser control in our application is invisible and we call Navigate2 and after a page is loaded - ExecWB (OLECMDID_PRINT, MSOCMDEXECOPT_PROMPTUSER, NULL, NULL);. We compile our code in VC++ 6.0 using _UNICODE.
    Thank you for the http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/bc7a73df-d4e0-4292-83e4-80d58fc765af/ link! We have exactly the same problem. I see there is no solution...

    Regards 
  • Friday, October 02, 2009 5:38 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    I performed the same test on Windows XP (SP3) + IE8, and did not see the problem.

    Instead of using VC++6 which is no longer supported, I used VS2008 with SP1 to compile the project.

    To further narrow down the problem, I suggest that you perform these tests:

    1. To determine whether the problem is related to the specific webpage that is loaded into your webbrowser control, please navigate the webbrowser to http://www.bing.com, which I have tested.

    2. Try upgrading your VC++6 project to higher versions of VS, e.g. VS2008. Also try removing the WebBrowser ActiveX control from your project, and add again in the new development environment.

    3. Try the new OLECMDID_PRINT2 command:
    http://msdn.microsoft.com/en-us/library/ms691264(VS.85).aspx
    According to its doc, OLECMDID_PRINT2 refers to File menu's updated Print command.

    Regards,
    Jialiang Ge

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Monday, October 05, 2009 11:33 AMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Jialiang Ge,

    Thank you for your answer.

    We made additional tests:
    The problem happens only when we send printouts in sequence (in loop).

    1)  It happens also when navigate to http://www.bing.com.
    2) We can not move to higher version of VS now.
    3) OLECMDID_PRINT2 is not defined when using VC++ 6.0.

    Regards

  • Wednesday, October 14, 2009 10:42 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What do you mean by send printouts in sequence? Could you please give some samples?

    Thanks
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Thursday, October 15, 2009 8:07 AMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We create bulk of printouts - HTML files (created on hard disk) - and we send them one by one for printing.
    Regards
  • Thursday, October 15, 2009 8:16 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Please send some HTMLs to me, and share with me the code that you send them for printing. I will test them in my lab.

    My mailbox is: jialge at microsoft.com

    Regards,
    Jiailang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Thursday, October 15, 2009 2:21 PMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Jiailang Ge,

    I sent you the code and HTML files by e-mail.

    Thank you!
  • Monday, October 19, 2009 10:59 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks. I have received your code. I will test them and update you about my findings.

    Regards,
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Monday, October 19, 2009 11:24 AMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks!
  • Tuesday, October 20, 2009 7:55 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello in_ks

    I tested your code. My test application hangs when loading the html files because of the while + sleep loop in the UI thread:

     int iCounter = 0;
     while (lState<READYSTATE_LOADED) {
      lState = m_Browser.get_ReadyState();
      Sleep(1000);
      iCounter++;
     }

    It's not a good practice to sleep in UI thread. It will cause your application to hang.

    I start to feel that you actually called the method PrintHTMLDirect from a non-UI thread. Could you please check it for me?

    In addition, it is better to check for READYSTATE_COMPLETE instead of READYSTATE_LOADED.
    http://msdn.microsoft.com/en-us/library/bb268229(VS.85).aspx

    I still cannot reproduce the problem.

    Regards,
    Jialiang Ge


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, October 20, 2009 10:00 AMbjarni Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have the same problem.
    But i can remove the problem by looping for ca 5 seconds and handle window msg and then it doesent crash.

    But that obviously is not a solution....

    for

     

    (int j=0; j<500; j++)

    {

    Sleep(10);

    HANDLE_WINMSG

    }

  • Tuesday, October 20, 2009 10:11 AMin_ks Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello 
    It is UI thread...
    Regards

  • Thursday, October 29, 2009 3:45 AMAlan_S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We are having the same exact issue only in C#

    The application takes a list of arguments and creates a list of HTML pages.

    This list is passed through the webbrowser control to print and keeps throwing this JSCript Error.

    webBrowser.DocumentText = htmlToPrint; - this is set once, before the below event is fired obviously.
    I've tried to implement about every solution I've found sleep, navigation, print2  to no avail.
    This is a enormous issue due to this application being deployed on Windows 2008 and IE8 configuration.
    We use Visual Studio 2005 

    Any help is greatly appreciated
    private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){
    System.Threading.
    Thread.Sleep(100);
    object o = null;
    SHDocVw.
    IWebBrowser2 wb = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance;
    wb.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
    SHDocVw.
    OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref o, ref o); 
    i
    f (reports.Count == 0)
    //Start a timer so the app doesn't end before the save to file dialog displays (when printing to file for testing)
    timer1.Start();
    else{
    currReport = reports[0];
    orientation = reports[1];
    string htmlToPrint = reports[2];
    reports.RemoveAt(0);
    reports.RemoveAt(0);
    reports.RemoveAt(0);
    webBrowser.DocumentText = htmlToPrint;
    }

  • Thursday, October 29, 2009 2:39 PMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks, bjarni.

    Do you see  "Internet Explorer script error" - Error on your side?


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Thursday, October 29, 2009 3:02 PMAlan_S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Yes, I get the Internet Explorer Script Error window with the following:

    Line: 2570   <- this actually changes I think
    Char: 1
    Error: Permission Denied
    Code: 0
    URL: res://ieframe.dll/preview.js

  • Tuesday, November 03, 2009 6:14 AMAlan_S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Any resolution on this. This issue is a high impact on a fairly sizeable customer of ours and Microsoft's.
    Why is this being pushed aside?
  • Tuesday, November 03, 2009 6:59 AMJialiang Ge [MSFT]MSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    I just found a possible solution for this problem. Please try it first and tell me the result. I'm digging into its cause.

    wb.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPR
    OMPTUSER, ref obj, ref obj);
    //Added a delay after issuing print command
    for (int i = 20; i-- > 0; )
    {
    Thread.Sleep(500);
    Application.DoEvents();
    }


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, November 10, 2009 6:47 PMAlan_S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    You are introducing a 10 Second pause between each print? I apologize but how is that a solution to a problem.  I have 10 reportes queued at a minimum so I'm looking at a user having to wait 10 minutes before they receive their report?

    If you noticed I already had a sleep above the statement so that wouldn't really make any difference.

    In addition I'm still getting an error.

  • Wednesday, November 18, 2009 3:15 PMGrand Prix Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a customer with the same issue.  We are printing produced HTML pages which have around a 5 or 10 second pause between each.  I am unable to reproduce the problem, but it plagues our customer.  I believe our customer has attempted to use a different PC and a different printer.  It seems related to some Windows Updates, but not sure.  Does anyone have a resolution?