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. Using CWebBrowser2 control with CString?

Using CWebBrowser2 control with CString?

Scheduled Pinned Locked Moved C / C++ / MFC
helphtmlquestion
7 Posts 3 Posters 0 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello, i use this control in dialog based application and i want to assign a CString value to them! I mean, show html content without calling .Navigate(...);

    // sample
    CString csHtmlContent = L"some very large text";
    CWebBrowserCtrl2 cWeb;
    // here assign CString-value to cWeb!

    Is that possible, any suggestion for this problem? It can be any other control who can show html content! Thanks for any help! termal

    V R 2 Replies Last reply
    0
    • L Lost User

      Hello, i use this control in dialog based application and i want to assign a CString value to them! I mean, show html content without calling .Navigate(...);

      // sample
      CString csHtmlContent = L"some very large text";
      CWebBrowserCtrl2 cWeb;
      // here assign CString-value to cWeb!

      Is that possible, any suggestion for this problem? It can be any other control who can show html content! Thanks for any help! termal

      V Offline
      V Offline
      Varghese Paul M
      wrote on last edited by
      #2

      You can write the HTML text into a temporary file and open that file in your web control using Navigate method by prefixing file:// in its URL.

      cheers Varghese Paul

      L 1 Reply Last reply
      0
      • V Varghese Paul M

        You can write the HTML text into a temporary file and open that file in your web control using Navigate method by prefixing file:// in its URL.

        cheers Varghese Paul

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi, thanks for answer, that is what i try to avoid, temporary file! regards termal

        1 Reply Last reply
        0
        • L Lost User

          Hello, i use this control in dialog based application and i want to assign a CString value to them! I mean, show html content without calling .Navigate(...);

          // sample
          CString csHtmlContent = L"some very large text";
          CWebBrowserCtrl2 cWeb;
          // here assign CString-value to cWeb!

          Is that possible, any suggestion for this problem? It can be any other control who can show html content! Thanks for any help! termal

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          Some thing like this,

              CComPtr<IDispatch> pDispDoc;
          CComVariant spVar(\_T("about:blank"));
          m\_Explorer.Navigate2(&spVar, 0, 0, 0, 0); // Just to initialise a blank doc
          
          
          **pDispDoc = m\_Explorer.get\_Document();**	
              CComQIPtr<IHTMLDocument2> spDoc(pDispDoc);
          
          VARIANT \*param;
          **CComBSTR spbStrHtmlText(OLESTR("<html><body>some very large text</body></html>"));**	SAFEARRAY \* psfArray = SafeArrayCreateVector(VT\_VARIANT, 0, 1);	
          SafeArrayAccessData(psfArray,(LPVOID\*) & param);
          param->vt = VT\_BSTR;
          param->bstrVal = spbStrHtmlText;
          SafeArrayUnaccessData(psfArray);
          **spDoc->write(psfArray);**	
              SafeArrayDestroy(psfArray);  
          

          See also [IHTMLElement::innerHTML ^] And have a look at IHTMLDom objects to have more controls over internal html nodes.

          L 2 Replies Last reply
          0
          • R Rajkumar R

            Some thing like this,

                CComPtr<IDispatch> pDispDoc;
            CComVariant spVar(\_T("about:blank"));
            m\_Explorer.Navigate2(&spVar, 0, 0, 0, 0); // Just to initialise a blank doc
            
            
            **pDispDoc = m\_Explorer.get\_Document();**	
                CComQIPtr<IHTMLDocument2> spDoc(pDispDoc);
            
            VARIANT \*param;
            **CComBSTR spbStrHtmlText(OLESTR("<html><body>some very large text</body></html>"));**	SAFEARRAY \* psfArray = SafeArrayCreateVector(VT\_VARIANT, 0, 1);	
            SafeArrayAccessData(psfArray,(LPVOID\*) & param);
            param->vt = VT\_BSTR;
            param->bstrVal = spbStrHtmlText;
            SafeArrayUnaccessData(psfArray);
            **spDoc->write(psfArray);**	
                SafeArrayDestroy(psfArray);  
            

            See also [IHTMLElement::innerHTML ^] And have a look at IHTMLDom objects to have more controls over internal html nodes.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Hello, yes that is what i need, and thanks very much for help!!! And thanks for the link! with best regards termal

            1 Reply Last reply
            0
            • R Rajkumar R

              Some thing like this,

                  CComPtr<IDispatch> pDispDoc;
              CComVariant spVar(\_T("about:blank"));
              m\_Explorer.Navigate2(&spVar, 0, 0, 0, 0); // Just to initialise a blank doc
              
              
              **pDispDoc = m\_Explorer.get\_Document();**	
                  CComQIPtr<IHTMLDocument2> spDoc(pDispDoc);
              
              VARIANT \*param;
              **CComBSTR spbStrHtmlText(OLESTR("<html><body>some very large text</body></html>"));**	SAFEARRAY \* psfArray = SafeArrayCreateVector(VT\_VARIANT, 0, 1);	
              SafeArrayAccessData(psfArray,(LPVOID\*) & param);
              param->vt = VT\_BSTR;
              param->bstrVal = spbStrHtmlText;
              SafeArrayUnaccessData(psfArray);
              **spDoc->write(psfArray);**	
                  SafeArrayDestroy(psfArray);  
              

              See also [IHTMLElement::innerHTML ^] And have a look at IHTMLDom objects to have more controls over internal html nodes.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hello, i have just one little question about this, if i try to show next html content, that is append to existing content, so i have two sites showed in this control! :doh: I think i should before i show next content, clear the existing text, but how, can you help me again with that? regards termal

              L 1 Reply Last reply
              0
              • L Lost User

                Hello, i have just one little question about this, if i try to show next html content, that is append to existing content, so i have two sites showed in this control! :doh: I think i should before i show next content, clear the existing text, but how, can you help me again with that? regards termal

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Hi, i solved my problem! termal

                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