Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Puzzling OnInitialUpdate() behavior for CHtmlView derived class

Puzzling OnInitialUpdate() behavior for CHtmlView derived class

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcomhosting
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #1

    Here is my code :-

    void CReportView::OnInitialUpdate()
    {
    Navigate2(_T("about:blank"),NULL,NULL);

    IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument();        
    if(!pDoc)
    {        
        return;
    }    
    
    HRESULT hr;
    SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1);
    VARIANT \*param;    
    
    MessageBox("L"); // If I comment out this line it fails
    
    BSTR bsData = m\_html.AllocSysString();
    hr =  SafeArrayAccessData(psa, (LPVOID\*)&param);
    param->vt = VT\_BSTR;
    param->bstrVal = bsData;
    hr = pDoc->write(psa);
    hr = pDoc->close();
    SysFreeString(bsData);
    SafeArrayDestroy(psa);        
    

    }

    You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish


    Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

    N G 2 Replies Last reply
    0
    • N Nish Nishant

      Here is my code :-

      void CReportView::OnInitialUpdate()
      {
      Navigate2(_T("about:blank"),NULL,NULL);

      IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument();        
      if(!pDoc)
      {        
          return;
      }    
      
      HRESULT hr;
      SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1);
      VARIANT \*param;    
      
      MessageBox("L"); // If I comment out this line it fails
      
      BSTR bsData = m\_html.AllocSysString();
      hr =  SafeArrayAccessData(psa, (LPVOID\*)&param);
      param->vt = VT\_BSTR;
      param->bstrVal = bsData;
      hr = pDoc->write(psa);
      hr = pDoc->close();
      SysFreeString(bsData);
      SafeArrayDestroy(psa);        
      

      }

      You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Okay, this is a sorta make-shift work-around :-)

      void CReportView::OnInitialUpdate()
      {
      CHtmlView::OnInitialUpdate();

      Navigate2(\_T("about:blank"),NULL,NULL);	
      

      }

      That's all :-) Now I have my own

      void CReportView::RenderView()
      {
      ...
      ...
      }

      This has sorta solved the issue. I call RenderView when I want to change the contents Nish :~


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      1 Reply Last reply
      0
      • N Nish Nishant

        Here is my code :-

        void CReportView::OnInitialUpdate()
        {
        Navigate2(_T("about:blank"),NULL,NULL);

        IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument();        
        if(!pDoc)
        {        
            return;
        }    
        
        HRESULT hr;
        SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1);
        VARIANT \*param;    
        
        MessageBox("L"); // If I comment out this line it fails
        
        BSTR bsData = m\_html.AllocSysString();
        hr =  SafeArrayAccessData(psa, (LPVOID\*)&param);
        param->vt = VT\_BSTR;
        param->bstrVal = bsData;
        hr = pDoc->write(psa);
        hr = pDoc->close();
        SysFreeString(bsData);
        SafeArrayDestroy(psa);        
        

        }

        You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

        G Offline
        G Offline
        Gavin Jerman
        wrote on last edited by
        #3

        An off topic question - how did you get your code snippet nicely formatted? Gavin

        N 1 Reply Last reply
        0
        • G Gavin Jerman

          An off topic question - how did you get your code snippet nicely formatted? Gavin

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Using the PRE tag :-)


          Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups