组件制作之二(一个简单组件的制作过程)[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 linzhengqun 的 blog

  begin

      ftimer:=ttimer.create(self);

      ftimer.enabled:=false;

      ftimer.interval:=1000;

      ftimer.ontimer:=ftimertimer;

  end;

begin

  inherited create(aowner);

  createtimer;

end;

//析构函数,先释放时间控件,再继承父类的析构函数

destructor ttimecount.destroy;

begin

  ftimer.free;

  inherited destroy;

end;

构造函数中还要设置该组件的外观和默认值,这里把它删去,到源代码再贴出来。

其中

ftimertimer;是很重要的函数,在该类中有声明:

procedure ftimertimer(sender:tobject);//时间控件的事件处理函数

在这个处理函数中,实现了计数值的递增并显示到容器中,此外,还在判断类的时间事件是否有足够条件触发了,如果有则调用dotimeout;过程,这个就是事件的调度函数啦:

//事件调度函数,将外部的事件处理函数和该类的事件方法指针联系起来

procedure ttimecount.dotimeout;

begin

  if assigned(ftimeout) then

本文关键:组件制作之二(一个简单组件的制作过程)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top