Some help with TTimer function please.

Discuss about Programming here. You may release your source, post guide and even ask questions!

Moderator: wizme

darknessproz
Sacrificer
Sacrificer
Posts: 27
Joined: Wed Jan 20, 2010 7:17 pm

Some help with TTimer function please.

Post by darknessproz »

This is how my program works.

There is a radiobox choice of 10 sec, 20 sec, 30 sec.

After choosing 1 and clicking the start button, the panel would start counting down from say, 10secs to 0. The problem i have now is to update the panel to reflect the countdown of the timer.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);

if timer = 10000 then
begin
timer1.Enabled := True;
timer1.Interval := 10000;
end;

end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
timer := 10000;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
timer := 20000;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
timer := 30000;
end;
some help with this?
wizme
Destiny General
Destiny General
Posts: 297
Joined: Sat Sep 05, 2009 1:40 pm

Re: Some help with TTimer function please.

Post by wizme »

hi, i nv work with delphi b4 but is there any method that can return the value of the timer? if can then u can spawn a new thread to run a loop to keep changing the value of the timer to a label. if there is no method on getting the return value, u can create a variable yourself and -1 every 1 sec in a loop also can.
Unlike science, love is like magic, there's no reason to it - wizme =)
Learn more of security, click here =)
darknessproz
Sacrificer
Sacrificer
Posts: 27
Joined: Wed Jan 20, 2010 7:17 pm

Re: Some help with TTimer function please.

Post by darknessproz »

i'm not too sure, i'm new to delphi. perhaps i'll wait for boredness to come in.
Boredness
The Emperor
The Emperor
Posts: 2539
Joined: Wed Aug 26, 2009 9:50 pm
Location: Singapore
Contact:

Re: Some help with TTimer function please.

Post by Boredness »

your code is way wrong bro.
Donate money to my paypal account @ danielongdequan1996@hotmail.com to keep this website alive!
darknessproz
Sacrificer
Sacrificer
Posts: 27
Joined: Wed Jan 20, 2010 7:17 pm

Re: Some help with TTimer function please.

Post by darknessproz »

hmm, than any suggestions on the right way? =x
wizme
Destiny General
Destiny General
Posts: 297
Joined: Sat Sep 05, 2009 1:40 pm

Re: Some help with TTimer function please.

Post by wizme »

why do you have a if statement to start the timer, if so, if you check your 20 or 30 sec, it will not meet the if statement and will not start countdown
Unlike science, love is like magic, there's no reason to it - wizme =)
Learn more of security, click here =)
darknessproz
Sacrificer
Sacrificer
Posts: 27
Joined: Wed Jan 20, 2010 7:17 pm

Re: Some help with TTimer function please.

Post by darknessproz »

its not the full code, there is also a if statement for 20sec and 30 sec. i can start the timer np, the problem now is how to display the countdown
Boredness
The Emperor
The Emperor
Posts: 2539
Joined: Wed Aug 26, 2009 9:50 pm
Location: Singapore
Contact:

Re: Some help with TTimer function please.

Post by Boredness »

i'm using my mac right now... i'll help you when i get back home.
Donate money to my paypal account @ danielongdequan1996@hotmail.com to keep this website alive!
darknessproz
Sacrificer
Sacrificer
Posts: 27
Joined: Wed Jan 20, 2010 7:17 pm

Re: Some help with TTimer function please.

Post by darknessproz »

i think i figured it out myself, but i would like to see the way you do it, as it seems my method is really inefficient. btw boredness, are there any books on delphi you can recommand?
wizme
Destiny General
Destiny General
Posts: 297
Joined: Sat Sep 05, 2009 1:40 pm

Re: Some help with TTimer function please.

Post by wizme »

darknessproz wrote:i think i figured it out myself, but i would like to see the way you do it, as it seems my method is really inefficient. btw boredness, are there any books on delphi you can recommand?
share your solution so ppl can learn =)

you can just remove all the if statement and just put the enable timer code in the start button

Also remember error checking, for example you only can allow the person to tick one check box
Unlike science, love is like magic, there's no reason to it - wizme =)
Learn more of security, click here =)
Post Reply