如何直接将HTML代码加载到TWebBrowser

wbRecvContent//为 webbrowser控件

 

procedure TFrmMain.ShowHtmlCentent(slt: TStrings);

var

  aMemory: TMemoryStream;

  pbuf: PAnsiChar;

begin

  aMemory := TMemoryStream.Create();

  try

    aMemory.Clear;

    slt.SaveToStream(aMemory);

    aMemory.Seek(0, soBeginning);

    wbRecvContent.Navigate('about:blank');

    while wbRecvContent.ReadyState < READYSTATE_INTERACTIVE do

      Application.ProcessMessages;

    if Assigned(wbRecvContent.Document) then

      (wbRecvContent.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aMemory));

  finally

    FreeAndNil(aMemory);

  end;

end;

你可能感兴趣的:(WebBrowser)