Autor Beitrag
Andreas_Sans
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Mi 28.05.03 16:31 
Hallo,

ich möchte einen Timer mit einem Button starten. Der timer soll dann weiterlaufen und ständig ein Editfeld in der die abgelaufene Zeit steht aktualisieren. Geht das und wenn ja, wie ?
TomT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 116

Suse 9.1 WinXP
D6 Pers
BeitragVerfasst: Mi 28.05.03 17:12 
meinst du sowas ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if timer1.Enabled = false then
  begin
    zeit := 0;
    timer1.Enabled := true;
  end
  else
    timer1.Enabled := false;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  zeit := zeit + timer1.Interval;
  edit1.Text := inttostr(zeit);
end;

_________________
...und da wurde mir klar, dass eine Toolbar keine Kneipe für Heimwerker ist.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 28.05.03 17:12 
Setz im ButtonClick-Ereignis Timer1.Enabled auf TRUE.
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mi 28.05.03 17:13 
Ja das geht:
Zum Aktivieren timer1.enabled:=true;
und die abgelaufende Zeit kannst du ja in einer Variablen speichern und ins editfeld bringen
Andreas_Sans Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Mi 28.05.03 19:23 
@ TomT : Danke hat geklappt. aber ich möchte das editfeld so machen, dass wenn (zeit DIV 1000) <10 soll er z.B. im editfeld 001 ausgeben, bei ((zeit DIV 1000) >9) and ((zeit DIV 1000) < 100) soll er z.B. 010 ausgeben und bei ((zeit DIV 1000) >100) soll er die Zahl einfach so reinschreiben. aber wenn ich eine if abfrage mache akzeptiert er diese nicht. gibt es da eine andere Möglichkeit ?
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mi 28.05.03 20:54 
bei mir akkzeptiert er es.
ausblenden Quelltext
1:
2:
3:
4:
zeit:=zeit+1;
if (zeit DIV 1000) <10  then edit1.text:='001';
if ((zeit DIV 1000) >9) and ((zeit DIV 1000) < 100) then edit1.text:='010';
if ((zeit DIV 1000) >100)   then edit1.text:=inttostr(zeit);
dauer nur ziemlich lange bis Zeit=100000.
Andreas_Sans Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Mi 28.05.03 21:09 
danke, da lag der fehler wohl bei mir.
TomT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 116

Suse 9.1 WinXP
D6 Pers
BeitragVerfasst: Do 29.05.03 00:13 
@Andreas_Sans: Ist Dir jetzt geholfen, oder brauchst du noch Hilfe?

_________________
...und da wurde mir klar, dass eine Toolbar keine Kneipe für Heimwerker ist.
Andreas_Sans Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Do 29.05.03 13:29 
nee alles klar jetzt, hab wohl irgendwas in der if abfrage falsch gehbt