Home > Back-end >  TCppWebBrowser change after the Document not load a local file?
TCppWebBrowser change after the Document not load a local file?

Time:10-26

The specific situation is: use the browser to save web pages to the local, want to pass TCppWebBrowser read and shows the page,
For some reason cannot use Navigate directly with Navigate2 open, then use the following method to change the Document TCppWebBrowser,
Void __fastcall TForm1: : SetHtml (TCppWebBrowser * WebBrowser, AnsiString Html)
{
Cost * Stream;
HGLOBAL hHTMLText;
IPersistStreamInit * psi.

If (WebBrowser - & gt; The Document==NULL) return;

HHTMLText=GlobalAlloc (GPTR, Html. The Length () + 1);
If (0==hHTMLText)
{
ShowMessage (GlobalAlloc "Error");
return;
}

CopyMemory (hHTMLText, Html. C_str (), Html. The Length ());
OleCheck (CreateStreamOnHGlobal (hHTMLText, true, & amp; The Stream));

OleCheck (WebBrowser - & gt; The Document - & gt; QueryInterface (__uuidof (IPersistStreamInit), (void * *) & amp; Psi));
OleCheck (psi - & gt; InitNew ());
OleCheck (psi - & gt; Load (Stream));

Psi - & gt; Release ();
Stream - & gt; Release ();
}
It can show the contents of the HTM, but cannot load the HTM pictures and some associated CSS, js file.
Smart questions such as how to solve?
  • Related