Guest:
Register
|
Login
|
Member List
|
Search
|
Statistics
|
FAQ
Language
----------
Simplifed Chinese
Traditional Chinese
English
CnPack Forum
»
CnVCL 组件包
» TcnTimerList如何重定义onTimer
‹‹ Last Thread
|
Next Thread ››
Poll
Trade
Reward
Activity
Printable Version
|
Email to Friend
|
Subscription
|
Favorites
Subject: TcnTimerList如何重定义onTimer
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#1
Post at 2008-8-30 18:00
Profile
|
Blog
|
P.M.
TcnTimerList如何重定义onTimer
我使用了TcnTimerList新建多个计时器,现在想用 自定义函数 处理到时,却不知道怎么做
下面的代码 编译总出错
unit MainForm;
interface
。。。
。。。
type
TForm1 = class(TForm)
。。。
procedure dao(Sender:TObject;PCNum:integer);
。。。
。。。
implementation
。。。
//需要执行的操作
procedure TForm1.dao(Sender:TObject;PCNum:integer);
begin
ShowMessage(IntToStr(PCNum));
end;
procedure createTimerList();
var i:Integer;
begin
for I := 1 to config1.PcNumber do
begin
Form1.ctl1.Items.Add;
Form1.ctl1.Items
.Enabled := False;
Form1.ctl1.Items
.OnTimer := Form1.dao(self,i) ;//接管。编译出错
end;
end;
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#2
Post at 2008-8-30 21:43
Profile
|
Blog
|
P.M.
赋值时,不用写括号与Self吧,后者是调用。
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#3
Post at 2008-8-31 00:24
Profile
|
Blog
|
P.M.
Form1.ctl1.Items.OnTimer := Form1.dao(self,i) ;//接管。编译出错
----------------------
那这一句,我应该怎么写呢
怎么把 i 传递过去呢
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#4
Post at 2008-8-31 10:53
Profile
|
Blog
|
P.M.
I不是在这儿传的,是TCnTimerItem自身在TCnTimerCollection中的Index吧。
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#5
Post at 2008-8-31 11:06
Profile
|
Blog
|
P.M.
这个I是 我自己的参数,用来确定是 哪个机器的 定时器亚,
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#6
Post at 2008-8-31 11:30
Profile
|
Blog
|
P.M.
对哇,是按顺序加的,I也正好是TCnTimerItem自身在TCnTimerCollection中的Index吧。
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#7
Post at 2008-8-31 11:53
Profile
|
Blog
|
P.M.
是这样,我初始化了(在for循环里动态初始化)好几个tcntimerlist 的item,这样当 一个item到时,我怎么知道是哪个 item呢?
? ?如果用item的index,我在源码里 也没发现 可以在ontimer()里 确定这个item的index的方法
? ?所以我想,在初始化item时,就把 item绑定的 机器号传到 它的ontimer里,这个 item的ontimer后,可以很简单 知道是哪个 机器?
[
本帖最后由 old_cnpack 于 2008-8-31 12:12 编辑
]
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#8
Post at 2008-8-31 14:26
Profile
|
Blog
|
P.M.
Sender 是 TCnTimerItem,强制转换后它的Index属性就是。
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#9
Post at 2008-8-31 14:32
Profile
|
Blog
|
P.M.
能不能给点 代码?谢谢
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#10
Post at 2008-8-31 14:33
Profile
|
Blog
|
P.M.
也可以在CnTimerList的OnTimer事件里头直接写,参数中有Index的。
old_cnpack
新警察
UID 40849
Digest Posts 0
Credits 22
Posts 8
点点分 22
Reading Access 10
Registered 2008-8-30
Status Offline
#11
Post at 2008-8-31 14:53
Profile
|
Blog
|
P.M.
也可以在CnTimerList的OnTimer事件里头直接写,参数中有Index的。
------------------------------
谢谢,我明白了。CnTimerList的OnTimer 也可以 用在他的 item上
Poll
Trade
Reward
Activity
CnPack Forum
CnPack English Forum
> CnWizards IDE Wizards
> CVSTracNT
> Announcements & Others
All times are GMT++8, the time now is 2024-11-22 13:25
Powered by
Discuz!
5.0.0
© 2001-2006
Comsenz Inc.
Processed in 0.010132 second(s), 7 queries , Gzip enabled
TOP
Clear Cookies
-
Contact Us
-
CnPack Website
-
Archiver
-
WAP
Member's CP Home
Edit Profile
Credits Transaction
Public User Groups
Buddy List
Main
Page Views
User Agents
Posts History
Top Forums
Top Threads
Post Ranking
Credit Ranking
Online Time
Team
Moderation Stats