刚开始学delphi 书上关于timer控件就几句话过去了 看起来也挺简单的 但是今天用起来才发现,我不知道什么时候设置enabled什么时候是true什么时候是false;比如说 最简单的:我想要让label1.caption:='hello!';
那么我应该在buttonclick中写什么?在timerTimer中写什么?书上说timer里要写要做的事情,那么button里什么都不写了么?大家都说说看 我刚开始学 哥哥姐姐们随便说句话也都是我的经验啊 还希望不吝赐教 谢谢大家了
那么我应该在buttonclick中写什么?在timerTimer中写什么?书上说timer里要写要做的事情,那么button里什么都不写了么?大家都说说看 我刚开始学 哥哥姐姐们随便说句话也都是我的经验啊 还希望不吝赐教 谢谢大家了
解决方案 »
- 如何用Delphi实现触发TWebBrowser打开的一个页面上的某个链接的onMouseDown事件
- 请问谁有<<数据库系统概念(第四版)>>中文版的电子书啊??
- 快 Grid+ADO+Access的问题 解决立刻结账!!!!
- 达人乱入>>>>>>: Indy中如何实现连接超时?
- 怎样通过Delphi程序直接放mp3?
- 关于自定义组件的编写,谁有好的学习材料?200求!
- 如何制作类似windows media player 最小化后可以出现在工具栏上(具有控制按钮的那种),不是出现在任务栏上的图标。[
- delphi6为何自动关闭?
- 单线程数据库操作中的一个问题
- delphi clientdataset.open出错
- 世界上最让人无奈的事情是回小白的帖子
- delphi如何获取汉字拼音及音标?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Timer1: TTimer;
Button1: TButton;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
var
i :Integer;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled :=True;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
i :=i+1;
Label1.Caption :=IntToStr(i);
end;end.
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Caption :='Hello!';
end;
就行了,然后可以手动设置timer1.Enabled属性为True,楼上的按钮事件是用程序实现的,就是点完按钮自动执行
Timer1Timer事件了,当然如果你默认设置是1秒钟后看到程序执行结果,如果想设置间隔的话,设置Inteval属性,里面是毫秒,例如1000是1秒钟。