Timer onTimer event handler

hi guys;
consider the class "TCashier":

[code]
class TCashier{
public:
TCashier();
void _fastcall timer1Timer(TObject *Sender);
private:
TTimer *timer1;
....
};
//-------
TCashier::TCashier()
{
timer1=new TTimer(Form1);
timer1->Interval=5000;
timer1->Enabled=true;
}
//------
void __fastcall TCashier::timer1Timer(TObject *Sender)
{
.....
}
[/code]
-----------------------------------------------------------------------
i've create the timer component dynamically, and wrote its event handler manually, it's not working ;)
should i do any thing else!?!?

thanks

/******************/

The answer is: you wrote the event handler but did not set the timer's OnTimer to it!

[code]
class TCashier{
public:
TCashier();
void _fastcall timer1Timer(TObject *Sender);
private:
TTimer *timer1;
....
};
//-------
TCashier::TCashier()
{
timer1=new TTimer(Form1);
timer1->Interval=5000;
timer1->Enabled=true;
timer1->OnTimer = Form1->timer1Timer; //Or something like it
}
//------
void __fastcall TCashier::timer1Timer(TObject *Sender)
{
.....
}
[/code]


--------------------------------------------------------------------------------



Good luck,
bilderbikkel


Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories