H
huanzhugege
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟我刚学多线程,自己做了一个程序,可是总是出错,代码如下:
主程序:
crazyclick1:Tcrazyclick;//tcrazyclick是我自定义的一个线程
...
procedure TForm1.Button1Click(Sender: TObject);
begin
crazyclick1.Resume;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
crazyclick1:=Tcrazyclick.create(edit1.Text);
end;
Tcrayclick线程代码
unit crazyclick;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls;
type
Tcrazyclick = class(TThread)
webbrowser1:Twebbrowser;
private
{ Private declarations }
protected
url1:string;
procedure Execute;
override;
procedure webbrowser1Downloadcomplete(sender:Tobject);
public
finishednum:integer;
constructor create(url:string);
end;
implementation
constructor Tcrazyclick.create(url:string);
begin
inherited create(True);
finishednum:=0;
url1:=url;
end;
procedure Tcrazyclick.webbrowser1Downloadcomplete(sender:Tobject);
begin
try
webbrowser1.Refresh;
inc(finishednum);
except
on exceptiondo
end;
end;
procedure Tcrazyclick.Execute;
begin
webbrowser1.Navigate(url1);//执行到此处时总是出错
{ Place thread code here }
end;
end.
执行到上边注释的那句时总是出错,请帮助我
主程序:
crazyclick1:Tcrazyclick;//tcrazyclick是我自定义的一个线程
...
procedure TForm1.Button1Click(Sender: TObject);
begin
crazyclick1.Resume;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
crazyclick1:=Tcrazyclick.create(edit1.Text);
end;
Tcrayclick线程代码
unit crazyclick;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls;
type
Tcrazyclick = class(TThread)
webbrowser1:Twebbrowser;
private
{ Private declarations }
protected
url1:string;
procedure Execute;
override;
procedure webbrowser1Downloadcomplete(sender:Tobject);
public
finishednum:integer;
constructor create(url:string);
end;
implementation
constructor Tcrazyclick.create(url:string);
begin
inherited create(True);
finishednum:=0;
url1:=url;
end;
procedure Tcrazyclick.webbrowser1Downloadcomplete(sender:Tobject);
begin
try
webbrowser1.Refresh;
inc(finishednum);
except
on exceptiondo
end;
end;
procedure Tcrazyclick.Execute;
begin
webbrowser1.Navigate(url1);//执行到此处时总是出错
{ Place thread code here }
end;
end.
执行到上边注释的那句时总是出错,请帮助我