打印本文 打印本文 关闭窗口 关闭窗口
组件制作之二(一个简单组件的制作过程)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3426  更新时间:2009/4/23 18:34:07  文章录入:mintao  责任编辑:mintao
    Font.Style:=[fsBold,fsUnderline];;

    BevelOuter := bvLowered      ;

    Caption:=''''0'''';

  end;

begin

  inherited Create(AOwner);

  FCount:=0;

  FInterval:=TenM;

  FActive:=False;

  TimeLen:=600;//十分钟,六百秒

  TimeNum:=0;

  CreateTimer;

  setView;

end;

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

destructor TTimeCount.Destroy;

begin

  FTimer.Free;

  inherited Destroy;

end;

//设置时间事件发生间隔,财时要赋相应的间隔秒数

procedure TTimeCount.SetInterval(I:TInterval);

begin

  if FInterval<>I then

  begin

    FInterval:=I;

    case FInterval of

    TenM: TimeLen:=600;

    TwentyM:TimeLen:=1200;

    ThirtyM: TimeLen:=1800;

    FortyM: TimeLen:=2400;

    FiftyM:TimeLen:=3000;

    SixtyM:TimeLen:=3600;

    end;

  end;

end;

 

procedure TTimeCount.SetActive(A:boolean);

begin

  if FActive<>A then

  begin

      FActive:=A;

      TimeNum:=0;

  end;

end;

 

procedure TTimeCount.pause;

begin

 if FTimer.Enabled then

  FTimer.Enabled:=False;

end;

 

procedure TTimeCount.Resume;

begin

  if not FTimer.Enabled then

    FTimer.Enabled:=True;

end;

 

procedure TTimeCount.stop;

begin

  FTimer.Enabled:=False;

  FCount:=0;

  TimeNum:=0;

  caption:=''''0''''

end;

 

procedure TTimeCount.start;

begin

  if (not FTimer.Enabled)and(TimeNum=0) then

     FTimer.Enabled:=True;

end;

 

//最重要的时间函数,用于调用该类的事件触发高度函数。

//以及在容器中显示计数值

procedure TTimeCount.FTimerTimer(Sender:TObject);

begin

  inc(FCount);

  if (FCount mod 3600)=0 then FCount:=0;

  Caption:=InttoStr(FCount);//这个就是显示计数值

  inc(TimeNum);

  if (TimeNum=TimeLen)and(FActive) then

  begin

       DoTimeOut;

       TimeNum:=0;

  end;

end;

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

procedure TTimeCount.DoTimeOut;

begin

&

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口