寻找DELPHI多线程例程 高手快来
来源:百度知道 编辑:UC知道 时间:2024/06/21 01:33:11
unit bncthrd;
interface
uses
winprocs,classes,graphics,extctrls;
type
tbouncethread=class(tthread)
private
fshape:tshape;
fxspeed:integer;
fyspeed:integer;
procedure moveshape;
protected
procedure execute;override;
public
constructor create(suspended:boolean;shape:tshape;xspeed,yspeed:integer);
propertyshape:tshapereadfshape;
end;
implementation
procedure tbouad.moveshape;
var
maxheight,maxwidth:integer;
begin
with fshape do
begin
left:=left+fxspeed;
top:=top+fyspeed;
if(left=0) or(left+width=parent.width)then
fxspeed:=fxspeed*-1;
if(top=0)or(top=height+parent.height)then
fyspeed:=fyspeed*-1;
end;
end;
procedure tbouncethread.execute;
begin
while not terminated do
begin
synchronize(moveshape);
end;