How to load an HTML document from a stream into a TCppWebBrowser.

By: mykle hoban

Abstract: This article describes how to load a document out of a stream (memory, file, etc.) into an instance of the Internet Explorer control.


How can I do the equivalent of LoadFromStream within a TWebBrowser (IE control)?


Assuming that your HTML document is contained within Memo1, the code snipped below should illustrate how to load it from a stream into a TCppWebBrowser.

void __fastcall TForm1::Button1Click(TObject *Sender)
  TMemoryStream *stm = new TMemoryStream();

  IPersistStreamInit *psi;

  //if you pass soOwned instead, the stream will be freed for you
  TStreamAdapter *sa = new TStreamAdapter(stm,soReference);

  if (SUCCEEDED(wb->Document->QueryInterface(IID_IPersistStreamInit,(void **)&psi)))

  delete stm;

Server Response from: ETNASC03