Page 2 of 3

Re: Some help with TTimer function please.

Posted: Sun Feb 07, 2010 3:53 pm
by darknessproz
its basically setting var timer := 10, and use a timer to -1 every 1000 interval while updating the caption.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
Label2.Caption :='Active';
Button1.Enabled := False;
Button2.Enabled := True;

Timer1.Enabled := True;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Label2.Caption :='Inactive';
Button1.Enabled := True;
Button2.Enabled := False;
Timer1.Enabled := False;
end;

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

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

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
timer := 30;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer := timer - 1;
Panel1.Caption := IntToStr(timer);

if timer = 0 then
begin
 Timer1.Enabled := False;
 end;
end;

Re: Some help with TTimer function please.

Posted: Sun Feb 07, 2010 4:48 pm
by wizme
yea cheers =)

Re: Some help with TTimer function please.

Posted: Sun Feb 07, 2010 5:31 pm
by darknessproz
so boredness, is the way i'm doing it correct?

Re: Some help with TTimer function please.

Posted: Mon Feb 08, 2010 10:05 pm
by Boredness
you did it wrongly.
you could use the caption and -1 to the value and stop the caption from going after 0.. like -1...

Re: Some help with TTimer function please.

Posted: Tue Feb 09, 2010 4:09 pm
by darknessproz
i stopped it from going to negative value by doing a if timer = 0 then Timer1.Enabled = False

does the way i'm doing it give rise to any major issues?

Re: Some help with TTimer function please.

Posted: Tue Feb 09, 2010 10:15 pm
by Boredness
caption = 0 den disable... i'll show u the source...
anyways, what are you doing with it?

Re: Some help with TTimer function please.

Posted: Wed Feb 10, 2010 3:37 pm
by darknessproz
its sorta a parental control thing to shutdown the computer.

Re: Some help with TTimer function please.

Posted: Wed Feb 10, 2010 3:55 pm
by wizme
darknessproz wrote:its sorta a parental control thing to shutdown the computer.
you sure u making a parental control to shut down coms or use it ask prank? lol
how old are you ?

Re: Some help with TTimer function please.

Posted: Wed Feb 10, 2010 4:34 pm
by darknessproz
lol 16, its sorta a fun thing, but for school as well.

Re: Some help with TTimer function please.

Posted: Thu Feb 11, 2010 3:50 pm
by Boredness
lmao shut down a computer... nice