//--------------------------------------------------------------------------- #include #pragma hdrstop #include "CBLabelH.h" #pragma package(smart_init) //--------------------------------------------------------------------------- // ValidCtrCheck is used to assure that the components created do not have // any pure virtual functions. // static inline void ValidCtrCheck(TCBLabel *) { new TCBLabel(NULL); } //--------------------------------------------------------------------------- __fastcall TCBLabel::TCBLabel(TComponent* Owner) : TLabel(Owner) { AText = "http://cyfbar.republika.pl/"; AInterval = 500; Timer = new TTimer(NULL); Timer->Enabled = false; Timer->Interval = Interval; Timer->OnTimer = TimerTimer; t = 0; } //--------------------------------------------------------------------------- __fastcall TCBLabel::~TCBLabel(void) { delete Timer; } //--------------------------------------------------------------------------- namespace Cblabelh { void __fastcall PACKAGE Register() { TComponentClass classes[1] = {__classid(TCBLabel)}; RegisterComponents("CyfBar", classes, 0); } } //--------------------------------------------------------------------------- void __fastcall TCBLabel::SetAText(String tekst) { AText = tekst; } //--------------------------------------------------------------------------- void __fastcall TCBLabel::SetAInterval(int a) { AInterval = a; Timer->Interval = AInterval; } //--------------------------------------------------------------------------- void __fastcall TCBLabel::Execute(void) { Timer->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TCBLabel::TimerTimer(TObject *Sender) { t++; if(t <= AText.Length()) Caption = Text.SubString(1, t); if(t > AText.Length()) { Timer->Enabled = false; t = 0; } } //---------------------------------------------------------------------------