Hi i have problem it stopped my progress
I need to starttimer 200seconds to 0 (countdown in caption) by click on button, i have 48 buttons which are timers On google i found some about threads but dunno how to use it
timer_01.cpp:
__fastcall timer_01::timer_01(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
void __fastcall timer_01::Execute(TButton* buton)
{
if(buton->Caption=="Flash"){
for(int i=flash_time;i>0;i--){
buton->Caption=i;
Sleep(1000);
};
}
}
//---------------------------------------------------------------------------
and my button in main_program.cpp
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Execute(Button4);
}
and include in main_program.cpp
#include "timer_01.h"
my main_program.h constructor i added:
void __fastcall Execute(TButton* buton);
Your code is the completely wrong way to use
TThread
. Try something more like this instead:timer_01.h:
timer_01.cpp:
main_program.cpp
With that said, you don't really need a
TThread
for such a simple timer. ATTimer
would work just as well: