Autor Beitrag
Locke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 18:11 
Hallo Leute,
ich moechte in meinem Programm gerne eine Uhr anzeigen lassen, welche die Zeit runterzaehlt!
Die Uhr soll von 300 Sekunden auf 0 runterzaehlen, das habe ich ja soweit auch schon fertig und ist mir im nachhinein aufgefallen das es immer nach einer sekunde um eine zahl gesenkt werden soll und nicht in wenigen millisekunden ^^

ich poste mal fix noch meinen quelltext dazu:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1.Caption := IntToStr (autosave) + ' s';
  Autosave := 360;
  repeat dec (Autosave,1)
  until Autosave = 0;
end;


Jetzt muss ich halt nur noch einbauen, das jeweils nach einer sekunde um ein wert runtergzaehlt werden soll, ich weiss nur leider ueberhaupt nicht wie ich das anstellen soll :(

ich hoffe das ihr mir weiterhelfen koennt ;)

danke schonmal

mfg Locke

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 12.01.06 18:17 
Moin!

Du mußt die Zählervariable (klassen-)global deklarieren und einen Timer mit .Interval := 1000 einsetzen, in dessen OnTimer-Ereignis du runterzählst und bei 0 was machst.

cu
Narses
Bruder Lal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 31

WIN XP
Delphi 2005
BeitragVerfasst: Do 12.01.06 18:18 
ausblenden Delphi-Quelltext
1:
  timer1.interval:=1000;					

edit: Narses war schneller^^
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 18:57 
Hmm ich hab da auch schon an einen Timer gedacht gehabt, aber ich wusste net so recht ^^

Jetzt muss sich nur doch das Label aktualisieren, wie macht man das denn?

ausblenden Quelltext
1:
Label1.Refresh					

funktioniert nicht :(

thx

mfg Locke


Zuletzt bearbeitet von Locke am Do 12.01.06 18:59, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 12.01.06 18:58 
Moin!

Machst du alles im Timer-Ereignis.

cu
Narses
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 19:15 
Aber mit welchem Befehl genau?

Wie oben schon gesagt, habe ich Label1.Refresh schon ausprobiert und nen anderer Befehl faellt mir net ein ^^

thx

mfg Locke
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 19:22 
Hallo,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Timer1Timer(Sender: TObject);
begin

Label1.Caption := IntToStr (autosave) + ' s';
if autosave>0 then dec(autosave);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Autosave := 360;
end;

So geht es bei mir. Noch Fragen? :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 19:25 
Dieses Teilproblem ist ja schon geklaert ^^

Es soll jetzt wie gesagt nur noch das Label jede Sekunde refreshed werden.
Aber das funktioniert mit

ausblenden Quelltext
1:
2:
3:
[...]onTimer[...]
Label1.Refresh;
[...]


leider nicht :(

mfg Locke
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 12.01.06 19:32 
Du sollst auch nicht refresehen, sondern immer die Variable (hier: Autosave) mit inc(Autosave); um eines erhöhen und dann mit Label1.Caption anzeigen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 19:51 
Ja das hab ich ja schon, aber es bleibt immer die Zahl 360 im Label stehen, die veraendert sich nicht!

mfg Locke
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 19:52 
user profile iconGTA-Place hat folgendes geschrieben:
Du sollst auch nicht refresehen, sondern immer die Variable (hier: Autosave) mit inc(Autosave); um eines erhöhen und dann mit Label1.Caption anzeigen.


Die Variable 'autosave' beinhaltet doch die Azahl der Sekunden bis zum nächsten autosave oder nicht?

Warum muss man sie dann erhöhen? :gruebel:

Man zählt sie auf null runter, führt den autosave aus und stellt sie wieder zurück. Oder nicht? Hab ich das jetzt richtig verstanden?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 19:53 
@ locke:

Am besten, doch gibst und mal den gesamten betreffenden Code, weil ich jetzt nicht mehr durchsehe...

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 12.01.06 19:57 
user profile iconKoller hat folgendes geschrieben:
Man zählt sie auf null runter, führt den autosave aus und stellt sie wieder zurück. Oder nicht? Hab ich das jetzt richtig verstanden?

Er zählt sie zur Zeit im OnCreate mit repeat until auf 0 in einer Zeit, die in einem Bereich weniger als Millisekunden liegt. Und dann will er ne Zeit stoppen. Klingt merkwürdig, ist es auch ^^

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 20:01 
Aber was spricht denn gegen meine Variante?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 12.01.06 20:06 
2 Sachen:

1. Ich hab das dec(); übersehen. Sry.
2. Er will ne Stoppuhr und keinen Countdown.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 20:12 
Wenn er ne Stoppuhr will, dann soll er sich einen Button bauen, wo er dann timer1.enabled auf false setzt, dann hält das Label auf sich zu verändern :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 20:31 
Ok ... ich will einen Countdown ^^ mir ist das Wort nicht eingefallen :D

Zur zeit sieht das ganze wie folgt aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormCreate(Sender: TObject);
begin
Autosave := 360;
Label1.Caption := IntToStr (autosave) + ' s';
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.TTimer(Sender: TObject);
begin
dec (Autosave, 1);
end;


Jetzt hab ich nur das Problem das das Label indem die Zeit steht (Label1) nicht refreshed wird, es zeigt also immer die zahl 360 an!

Jetzt verstanden? ^^

thx

mfg Locke

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 12.01.06 20:34 
Wenn Du die Lösung schon bekommst von Koller warum probierst Du's nicht aus ?
Dann würdest Du deinen Fehler auch sehen.
Locke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Win 2000
Delphi 7 PE
BeitragVerfasst: Do 12.01.06 20:41 
Oh mein Gott du hast recht, ich habe das verwechselt.

Tut mir Leid :(

Ich hab da beim lesen nicht richtig hingekuckt, weil es genau so aussah wie eine Variante die ich schon probiert habe.

Sorry
Sorry
Sorry

1000x Sorry

Danke an alle :)

mfg Locke