Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

VCL – Load HTML code in TWebBrowser

Digital Innovation Partner

VCL – Load HTML code in TWebBrowser

Easy HTML editor with instant preview into TWebBrowser

Component to use:

– TSynedit
– TSynHTMLSyn
– TWebBrowser
– TTimer (set Interval 1000)
– TSplitter (set Align alLeft)

Here the code:

procedure TForm1.SynEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Doc: Variant;
begin
  Timer1.Enabled := False;

  if not Assigned(WebBrowser1.Document) then
    WebBrowser1.Navigate('about:blank');

  Doc := WebBrowser1.Document;
  Doc.Clear;
  Doc.Write(SynEdit1.Lines.Text);
  Doc.Close;
end;