Web editor Diy Dreamweaver, FrontPage and other web editing tools we have been familiar with it. But have you ever thought about making our own "web editor" for yourself.
WebBrowser controls from Delphi make us dream come true, and it is not difficult to achieve it.
First create a new project, drag a PageControl control on Form1, build 2 Tabsheet, TabSheet1 and TabSheet2. Drag and drop the richedit1 control on TabSheet1, drag and drop the WebBrowser1 control on TabSheet2. The basic properties of these controls are set to: tabsheet1: caption = 'html code' tabsheet1: caption = 'preview' richedit1: align = alclient webbrowser1: align = AlClient
Richedit is used to write HTML code, WebBrowser performs a visual preview for the code. The program provides a basic web template in the initialization phase, and we can write HTML code on this basis. The core code of the program is WebBrowser1.OleObject.Document.body.innerhtml: = shtml; this sentence, if you carefully discover, you must find more useful features. The drawings are example screenshots of this program run.
This program is implemented in Win98, Delphi5.0, IE5.0 environment. The complete code procedures are as follows: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, SHDocVw, ComCtrls; type TForm1 = class (TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; WebBrowser1: TWebBrowser; RichEdit1: TRichEdit; procedure FormCreate (Sender: TObject); procedure TabSheet2Show (Sender: TObject); private {Private declarations} public {public declarations} end; var Form1: TForm1; Const lf = # 10 ; // Railing information {$ r * .dfm}
Procedure TForm1.FormCreate (Sender: Tobject); begin // Settings window title: CAPTION: = 'web editor DIY'; // Initialization WebBBRowser1.naviGate ('About: blank'); // Generate web code template: Richedit1 .Text: = '' lf '