delphi做浏览器(100分)

  • 主题发起人 主题发起人 紫荆
  • 开始时间 开始时间

紫荆

Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi做了一简单的浏览器程序,运行后不断地出现各种错误。要么不能编译,要么打开一网站后出现乱七八糟的提示。哪位高手,帮帮忙吧,小女子献上100大元。
 
如何帮?要不拿出来供大家学习学习下!~
 
以下是代码:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, OleCtrls, SHDocVw, ComCtrls;

type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
WebBrowser1: TWebBrowser;
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ComboBox1: TComboBox;
OpenDialog1: TOpenDialog;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure WebBrowser1DownloadBegin(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure WebBrowser1TitleChange(Sender: TObject;
const Text: WideString);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure gotopage(geturl:string);
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
procedure tform1.gotopage(geturl:string);
//var
//newurl1:widestring;
begin
// newurl1:=widestring(geturl);
webbrowser1.Navigate(geturl);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if opendialog1.Execute then
gotopage(opendialog1.FileName);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
gotopage(combobox1.Text);
end;

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
gotopage(combobox1.Text);
end;

procedure TForm1.WebBrowser1DownloadBegin(Sender: TObject);
begin
statusbar1.Panels[0].Text:='downloading'+ webbrowser1.LocationURL+'...';
end;

procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
var
newurl:string;
begin
statusbar1.Panels[0].Text:='done';
newurl:=webbrowser1.LocationURL;
if (newurl<>'')and (combobox1.Items.IndexOf(newurl)<0) then
combobox1.Items.Add(newurl);
end;

procedure TForm1.WebBrowser1TitleChange(Sender: TObject;
const Text: WideString);
begin
caption:=text;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
gotopage(extractfilepath(application.ExeName)+'default.htm');
end;

end.
 
建议你先看看webbrowser的源码里,所实现的那些接口方法,再提做浏览器的事。

这控件没法直接用。太烂。。。
 
去tomore.com上去下載一個范例吧,還可以,基本功能都有,或者下載myie的代碼研究下!
 
呵,还是先看看别人的源码吧,小妹妹.
 

Similar threads

回复
0
查看
1K
不得闲
D
回复
0
查看
947
DelphiTeacher的专栏
D
D
回复
0
查看
885
DelphiTeacher的专栏
D
后退
顶部