S
sugzh
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个有关THREAD的小程序,编译通过,但一运行就出错。
现将程序贴在此,请诸位大虾,指点小弟一二,小弟万万分感激!
小弟的信箱:su@263.net
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
thread = class(tthread)
private
fpanel : tpanel;
protected
procedure draw;
procedure execute
override;
public
constructor create(panel:tpanel);
end;
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
test : thread;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
constructor thread.create(panel:tpanel);
begin
inherited create(false);
fpanel:=panel;
freeonterminate:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.left:=0;
form1.width:=800;
panel1.left:=0;
panel1.width:=800;
test.create(panel1);
end;
procedure thread.draw;
var
delay :tdatetime;
hour,min,sec,msec,temp:word;
begin
delay:=time;
decodetime(delay,hour,min,sec,msec);
temp:=msec+100;
while temp>msec do
begin
delay:=time;
decodetime(delay,hour,min,sec,msec);
end;
fpanel.left:=fpanel.left+1;
end;
procedure thread.execute
var
i : integer;
begin
i:=0;
while i<10 do
begin
synchronize(draw);
i:=5;
end;
end;
end.
现将程序贴在此,请诸位大虾,指点小弟一二,小弟万万分感激!
小弟的信箱:su@263.net
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
thread = class(tthread)
private
fpanel : tpanel;
protected
procedure draw;
procedure execute
override;
public
constructor create(panel:tpanel);
end;
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
test : thread;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
constructor thread.create(panel:tpanel);
begin
inherited create(false);
fpanel:=panel;
freeonterminate:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.left:=0;
form1.width:=800;
panel1.left:=0;
panel1.width:=800;
test.create(panel1);
end;
procedure thread.draw;
var
delay :tdatetime;
hour,min,sec,msec,temp:word;
begin
delay:=time;
decodetime(delay,hour,min,sec,msec);
temp:=msec+100;
while temp>msec do
begin
delay:=time;
decodetime(delay,hour,min,sec,msec);
end;
fpanel.left:=fpanel.left+1;
end;
procedure thread.execute
var
i : integer;
begin
i:=0;
while i<10 do
begin
synchronize(draw);
i:=5;
end;
end;
end.