源码下载:
http://www.cnitblog.com/Files/shuyezi122/webbrowser做网页浏览.rar
下面是所有代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ImgList, OleCtrls, SHDocVw, StdCtrls, ExtCtrls,
ToolWin;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
Panel1: TPanel;
Edit1: TEdit;
Button9: TButton;
WebBrowser1: TWebBrowser;
ImageList1: TImageList;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ToolButton3: TToolButton;
Label1: TLabel;
StatusBar1: TStatusBar;
Timer1: TTimer;
procedure ToolButton8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure WebBrowser1DownloadBegin(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure WebBrowser1NewWindow2(Sender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
procedure WebBrowser1StatusTextChange(Sender: TObject;
const Text: WideString);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
nurl:string;
implementation
{$R *.dfm}
procedure TForm1.ToolButton8Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
webbrowser1.Navigate(edit1.Text);\\打开网页
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
try
webbrowser1.GoBack;\\返回
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.WebBrowser1DownloadBegin(Sender: TObject);
begin
statusbar1.Panels[0].Text:='正在打开'+edit1.Text;
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
statusbar1.Panels[0].Text:='完毕';
end;
procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
begin
Cancel:=true;
WebBrowser1.Navigate (nurl);\\在你自己应用程序中打开网页超连接,nurl来自下面
end;
procedure TForm1.WebBrowser1StatusTextChange(Sender: TObject;
const Text: WideString);
begin
nurl:=text;\\得到连接地址,给上面函数用
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
statusbar1.Panels[1].Text:=timetostr(now);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
statusbar1.Panels[2].Text:='元旦快乐';\\今天元旦,送自己的礼物
end;
procedure TForm1.ToolButton2Click(Sender: TObject);
begin
try
webbrowser1.GoForward ;
except
showmessage('没有记录了');
exit;
end;
end;
end.
得到webbrowser内网页源码
var
myitem:Olevariant;
begin
myitem := WebBrowser1.Document;
memo1.Lines.add(myitem.all.item(0).outerhtml);
end;
posted on 2008-12-31 23:29
小叶子 阅读(746)
评论(0) 编辑 收藏 引用 所属分类:
delphi网络编程