我的代码:
unit lab824_3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, StdCtrls, ExtCtrls, ComCtrls, ToolWin, OleCtrls,
SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
ImageList1: TImageList;
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
procedure WebBrowser1DownloadBegin(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
Try
WebBrowser1.GoBack;
except
showMessage('已经达到最早历史记录');
exit;
end;
end;
procedure TForm1.ToolButton2Click(Sender: TObject);
begin
try
WebBrowser1.GoForward;
except
ShowMessage('已经达到最后历史记录');
exit;
end;
end;
procedure TForm1.ToolButton4Click(Sender: TObject);
begin
WebBrowser1.Stop;
end;
procedure TForm1.ToolButton5Click(Sender: TObject);
begin
WebBrowser1.Refresh;
end;
procedure TForm1.ToolButton6Click(Sender: TObject);
begin
WebBrowser1.GoHome;
end;
procedure TForm1.ToolButton7Click(Sender: TObject);
begin
close;
end;
procedure TForm1.WebBrowser1DownloadBegin(Sender: TObject);
begin
statusBar1.Panels[0].Text:='正在连接地址:'+Edit1.Text;
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
statusBar1.Panels[0].Text:='完成:'+Edit1.Text;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
webBrowser1.Navigate(Edit1.Text);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
end.