Autor Beitrag
Peteroramer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

Windows XP
Delphi 7
BeitragVerfasst: So 19.02.06 21:06 
Hallo,

Wie kann ich bei Delphi 7 einen delay einsetzen? Ich komme von Pascal und versuche mir Delphi beizubringen. Darum sorry für diese teilweise dummen Fragen.


Moderiert von user profile iconChristian S.: Topic aus Delphi Tutorials verschoben am So 19.02.2006 um 20:09
Peteroramer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

Windows XP
Delphi 7
BeitragVerfasst: So 19.02.06 21:19 
Mit einem delay meine ich, dass die Bewegung einer Schleife zu zeigen.

Ich schreibe ein Programm wo in bestimmten Feldern die Farbe geändert wird. Ich nahm eine for ... to ... do Schleife und stellte die Bedingung if ... then ... . So wird mir aber bei der Ausgabe nur das Endergebnis gezeigt. Um dies zu verhindert sage ich repeat ... until ... . So funktioniert es aber auch nicht richtig.

In Pascal kann man in der Schleife ein Delay setzen und dies so dem Betrachter deutlich machen. Aber in Delphi exestiert dieser Befehl scheinbar nicht.

Hilfe notwendig.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 21:24 
hallo,

vllt hilft dir der befehl sleep(100); weiter
nun "schläft" dein programm für 100ms.
Wenn du diesen Befehl in eine For-Schleife einbauen würdest, müsste man eigentlich die eizelnen schritte besser sehen können.

wenn ich das jetzt richtig verstanden habe :roll:
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 19.02.06 21:33 
Sorry, aber da fehlt was.
Delphi wird die Schleife trotzdem erst durchlaufen lassen bevor du ergebnisse bekommst. Zauber-befehl hierzu:
Irgentwo Application.ProcessMessages; einfügen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Peteroramer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

Windows XP
Delphi 7
BeitragVerfasst: So 19.02.06 21:34 
Ich will das so machen, dass man zuerst die Fläche rot sieht, dann gelb, dann schwarz. Und das immer wider.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 19.02.06 21:37 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
for i:=0 to 100 do
begin
  case (i mod 3of //mir nich ganz sicher damit, aber so in etwa.. ^^
    0:Panel1.Color:=clRed;
    1:Panel1.Color:=clYellow;
    2:Panel1.Color:=clBlack;
  end;
  Application.ProcessMessages;
  sleep(50);
end;

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
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: So 19.02.06 21:38 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
for X := 1 to 1000 do
begin
  // tue irgendwas
  Y := GetTickCount;
  while GetTickCount - Y < 1000 do    // 1000 = 1 Sekunde
    Application.ProcessMessages;
end;

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 21:40 
ich persönlich hätte es mit einem Timer gemacht :roll:
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 19.02.06 21:40 
Das is ne gute möglichkeit, den Befehl Sleep(n) zu ersetzen... Sleep friert die komplette Anwendung ein. da ist GTA-Place's methode besser.
edit: Timer dagegen sind ungenau. Vorallem in Bereichen von unter 50 ms kommt meist ein viel zu großer delay bei raus. Ausserdem sind sie Ressourcenfresser, darüber gabs schonmal ne Diskussion in nem anderen Thread ^^

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 21:47 
ja, diesen thread hatte ich gelesen :lol:

user profile iconPeteroramer hat folgendes geschrieben:
Ich will das so machen, dass man zuerst die Fläche rot sieht, dann gelb, dann schwarz. Und das immer wider.

Ich dachte mir, dass der Timer als eine art endlos-schleife besser funktionieren würde.
Natürlich kann man auch endlos-schleifen mit einer while-schleife erreichen :roll:
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 19.02.06 21:50 
yop. gleicher Aufwand, nur optimiert wäre eine Whileschleife da. Allllllerdings sollte man das vielleicht in nen Thread auslager äääääähm aber damit kenn ich mich 0 aus... Nimm nen TTimer unter System. -.-

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 19.02.06 21:53 
user profile iconJayEff hat folgendes geschrieben:
Sleep friert die komplette Anwendung ein. da ist GTA-Place's methode besser.
Seine Methode in gut und in Farbe: www.delphi-library.d...chonender_23225.html

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert