//这个unit就是现成的定义
unit gothread;interfaceuses
Classes,forms,windows;type
go = class(TThread)
private
fm:tform;
step1:integer;
{ Private declarations }
protected
procedure Execute; override;
procedure walk;
public
constructor create(form:tform;s1:integer);
end;implementation
{ Important: Methods and properties of objects in VCL can only be used in a
method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure go.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ go }constructor go.create(form:tform;s1:integer);
begin
inherited create(false);
fm:=form;
step1:=s1;
Priority:=tpIdle;
freeonterminate:=true;
end;procedure go.walk;
var i,j:integer;
begin
with fm do begin
left:=0-width;
visible:=true;
j:=(screen.Width-width) div 2;
i:=1;
repeat
left:=left+i;
i:=i+step1;
inc(step1);
sleep(2*step1);
until left+i>j;
end;
end;procedure go.Execute;
begin
{ Place thread code here }
synchronize(walk);
end;end.//在另一个form中USES GOTHREADprocedure TForm3.FormCreate(Sender: TObject);
const logobmpfile='start.bmp';
VAR RUSH:GO;
begin
if FileExists(logobmpfile) then
begin
image1.picture.loadfromfile(logobmpfile);
width:=image1.Picture.Width;
height:=image1.Picture.Height;
left:=0-width;
SetWindowRgn(handle,CreateEllipticRgn(width-clientwidth,height-clientheight,clientwidth,clientheight),true);
rush:=go.create(self,1);
end
else
begin
release;
Application.CreateForm(TForm1, Form1);
end;//form 的create事件中只有 rush:=go.create(self,1);这一句创建了线成并执
行,这个线成是用来控制一个form出现时从做到右加速跑到屏幕中心就停止
unit gothread;interfaceuses
Classes,forms,windows;type
go = class(TThread)
private
fm:tform;
step1:integer;
{ Private declarations }
protected
procedure Execute; override;
procedure walk;
public
constructor create(form:tform;s1:integer);
end;implementation
{ Important: Methods and properties of objects in VCL can only be used in a
method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure go.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ go }constructor go.create(form:tform;s1:integer);
begin
inherited create(false);
fm:=form;
step1:=s1;
Priority:=tpIdle;
freeonterminate:=true;
end;procedure go.walk;
var i,j:integer;
begin
with fm do begin
left:=0-width;
visible:=true;
j:=(screen.Width-width) div 2;
i:=1;
repeat
left:=left+i;
i:=i+step1;
inc(step1);
sleep(2*step1);
until left+i>j;
end;
end;procedure go.Execute;
begin
{ Place thread code here }
synchronize(walk);
end;end.//在另一个form中USES GOTHREADprocedure TForm3.FormCreate(Sender: TObject);
const logobmpfile='start.bmp';
VAR RUSH:GO;
begin
if FileExists(logobmpfile) then
begin
image1.picture.loadfromfile(logobmpfile);
width:=image1.Picture.Width;
height:=image1.Picture.Height;
left:=0-width;
SetWindowRgn(handle,CreateEllipticRgn(width-clientwidth,height-clientheight,clientwidth,clientheight),true);
rush:=go.create(self,1);
end
else
begin
release;
Application.CreateForm(TForm1, Form1);
end;//form 的create事件中只有 rush:=go.create(self,1);这一句创建了线成并执
行,这个线成是用来控制一个form出现时从做到右加速跑到屏幕中心就停止
解决方案 »
- 关于和车载终端通信的问题!!!(200)
- 120分 求禁止DBLookupComboboxEh1的自动填充功能的方法
- 请问这是什么意思? 在线等.谢谢.
- CSDN 真正的高手请看 基数排序算法 要多少分都行。
- 2个字符串相连如何弄?
- 密码框
- 有点难度的问题,在delphi中运行几个外部应用程序,并设置外部应用程序窗口的大小和位置!
- Delphi 你--真--行!!!!(关于QuickReport控件的愤慨).
- DCOM的服务器端/客户端配置问题
- 关于Delphi+sqlserver+win2000的问题(系统等着上,急!)
- 请问有关用DELPHI开发WEB应用程序的经验、书和网站
- 求“BUTTON GROUP”控件。。就是QQ上那种“分组按纽”的控件,DELPHI中找不到。。。
如果你要是一个等待循环,必须得到返回值,那么就用application.processmessages,它是去处理了系统的其他消息.等于把对CPU的控制权交出去.
而如果你循环等待的东西与你循环完毕之后执行的内容毫无关系,就用多线程,你可以创建一个线程类,就如同 liuhelin(鹤林)说的那样,如果创建一个临时线程,可以直接用Delphi自己的函数,这样比较简单.