Programming Delphi Use the TWebBrowser as an html editor in delphi
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

How to enable the twebbrowser to be editing?
Inface, twebbrowser has a design mode state. It could be set to allow the user to edit the content of a webpage. In delphi, this function is very easy to be called.

See an example.

Create a new object, drag a TWebBrowser onto the form, double click the form and add the following codes to its creat event.

uses MSHTML;
procedure TForm1.FormCreate(Sender: TObject) ;
begin
  WebBrowser1.Navigate('http://codeback.com') ;
end;

In the webbrowser1's event, double click the onDocumentComplete event to add codes.
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
   const pDisp: IDispatch; var URL: OleVariant) ;
begin
   ((Sender as TWebBrowser).Document as IHTMLDocument2).designMode := 'on';
end;

Run the project, when the page loaded, move your mouse onto the webbrowser area and click, see what happen.

Notice that when finish the editing, the designMode should be set to 'no' for saving the document's change.

Use this function in c++builder, see How to make the TCppWebbrowser editable in c++ builder


Add comment


Security code
Refresh

Programming - Delphi