Autor Beitrag
mexx
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 22.04.03 13:49 
Jetzt komme ich mir schon eiu bissel mies vor, aber ergal wie es gemacht habe, es hat nie so funktioniert wie ich es wollte.

Ich habe einen wert 300 der im ein sekunden takt herabgezählt werden soll. Mein Problem war dass der timer den ich verwendet hat, ständig den ursprungswert 300 geladen hat, so dass immer nur 299 da stand. Wie kann ich es besser machen??
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Di 22.04.03 13:55 
ähm ich weis net was du machen willst sorry :(

kannst mal besser und verständlicher schreiben?


gr€€tz
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Di 22.04.03 13:58 
schau dir mal folgenden Code an

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
  Form1: TForm1;
  count: Integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  count := 300;
  Label1.Caption := IntToStr(count);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Dec(count);
  Label1.Caption := IntToStr(count);
  if count = 0 then
    count := 300;
end;

_________________
Viele Grüße
Jakob
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 22.04.03 14:01 
Thanks, genau was ich brauche. Count sagte mir bis heute garnix!
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 22.04.03 16:54 
Äh... Count muss dir auch nichts sagen, das ist der frei wählbare Name einer Ganzzahl-Variable (siehe Deklaration "var... Count:Integer"). Du hättest den Begriff Count auch durch Orkentoeter ersetzen können.

Cu,
Udontknow
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Di 22.04.03 16:59 
brrr, der Count(er) als globale Variable oje, die schöne OO.
Nu, der Timer frist ne Menge Resourcen und blockiert teilweise die Anwendung. Vieleicht wäre Application.OnIdle() ein netter Platz? Und dann direkt die Sekunden zählen sprich etwas Addition und Subtraktion von TDateiTime. Ganz neckisch wäre es , einen Thread zu basteln, natürlich nur, wenn sich's lohnt.
grez.
msch
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 22.04.03 18:33 
Nun, wenn ich Mexx richtig einschätze, wird er wohl noch nicht soweit sein, Threads zu basteln oder Ereignisse zur Laufzeit zuzuweisen...
Wieso blockiert der Timer denn die Anwendung? Doch nur immer zum Zeitpunkt der Ausführung des Ereignisses. Wenn man dort nur eine kleine Variable inkrementiert, wird das wohl kaum jemandem auffallen.

Cu,
Udontknow
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mi 23.04.03 15:56 
Das ist in diesem Falle richtig. Aber ein Timer läuft imho via Messages. Echt komplizierte Routinen in einem Timer bringen das Proggi zu stehen.
Selbst ausprobiert. Seit dem lieber mit Threads.
richtig nett wirds, wenn die Procedure im Timer noch nicht fertig ist, aber schon der nächste Timer ansteht.
grez
msch
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 23.04.03 17:34 
Wie ich bereits sagte: Das Inkrementieren einer Variable wird dies garantiert nicht bewirken... :wink:

Cu,
Udontknow