谁说不能?????好好看看unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
tmythread=class(tthread)
public
procedure execute;override;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
t:tmythread;
begin
t:=tmythread.Create(true); t.FreeOnTerminate:=true;
t.execute;
end;{ tmythread }procedure tmythread.execute;
begin
inherited;
form1.Label1.Caption:=datetimetostr(now);
sleep(10000);
form1.Label2.Caption:=datetimetostr(now);end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
tmythread=class(tthread)
public
procedure execute;override;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
t:tmythread;
begin
t:=tmythread.Create(true); t.FreeOnTerminate:=true;
t.execute;
end;{ tmythread }procedure tmythread.execute;
begin
inherited;
form1.Label1.Caption:=datetimetostr(now);
sleep(10000);
form1.Label2.Caption:=datetimetostr(now);end;end.
解决方案 »
- C#基于access的成绩录入系统
- delphi:operation cannot mix aggregate value with record-varying value 错误提示什么意思
- 有关DBGridEh 线程问题
- mssql中字段小数位数为5位,在delphi保存到数据库后,小数位数就是只有4位,晕.
- 怎样自定义打印机纸张(在线等)
- treeview节点展不开?
- 征集delphi群,知道的请高之
- 创建模态窗体的奇怪问题!提示“Cannot make a visible window modal.”
- 不为别的
- 如何为TDate类型的数据赋值?
- 关于windowapi中的SendMessage函数!!!!!!!
- DBgrid 的OnDrawDataCell 是什么时候发生的
我在线程中写sleep,在编译时告诉我‘sleep’是没有定义的语句/变量,搞不清楚是怎么回事?
没有人碰到过类似的问题吗?
在Sleep上边按F1,把帮助里的Unit的名字加进你程序的USES部分,再看看能不能!
1。在主程序中public部分声明一过程sleeptime;
2。在实现部分写过程为sleep(20000);
3。在线程中引用它。谢谢大家的支持!!
在线程uses语句中加入windows。
谢谢你的支持!