Autor Beitrag
T1g3r
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: Mi 04.05.05 16:28 
hi wie mach ich des, des mein programm so ca. 2 sec unterbricht und dann erst weiter macht???

Michel


Zuletzt bearbeitet von T1g3r am Di 10.05.05 14:45, insgesamt 1-mal bearbeitet
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mi 04.05.05 16:41 
Sleep(2000)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
wolke
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 240



BeitragVerfasst: Mi 04.05.05 16:41 
www.delphi-fundgrube.de/ -> "Wie erreiche ich, daß mein Programm eine Pause macht?"

Generell gibt es da drei Möglichkeiten.

1. Sleep
Die einfachste funktioniert aber nur in 32Bit-Programmen und legt das Programm für die angegebene Zeit komplett lahm:

ausblenden Delphi-Quelltext
1:
2:
3:
const Millisekunden = 1000;

Sleep(Millisekunden);


2. GetTickCount

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure Delay(ATime:Integer);
var
  Start : Integer
begin
  Start:=GetTickCount;
  repeat
    Application.ProcessMessages;
  until GetTickCount-Start > ATime;
end;


3. Timer
Im OnTimer-Ereignus von PauseTimer wird PrgPause auf False gesetzt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure Delay(Millisekunden : integer);
begin
  PrgPause := True;
  PauseTimer.Intervall := Millisekunden;
  PauseTimer.Enabled := True;
  While PrgPause Do
    Application.ProcessMessages;
  PauseTimer.Enabled := False;
end;
T1g3r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: Mi 04.05.05 16:47 
ok des hab ich reingemacht aber dann macht er anfangs ne pause und dann gehts einfach weiter obwohl er mehrmals ne Pasue machen soll, da ich es in einer schleife habe!!

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
procedure TForm1.FormCreate(Sender: TObject);
begin
  image1.canvas.create;
  randomize;
end;

procedure TForm1.BStartClick(Sender: TObject);
Var
  z,x1,y1,x2,y2,x3,y3,x4,y4 : integer;
begin
  x1 := 0;
  y1 := 20;
  x2 := 0;
  y2 := 40;
  x3 := 0;
  y3 := 60;
  x4 := 0;
  y4 := 80;
repeat
  z := Random(10)+1;
  image1.canvas.MoveTo(x1,y1);
  image1.Canvas.lineto(x1+z,y1);
  x1 := x1+z;
  Sleep(5);
  z := Random(10)+1;
  image1.canvas.MoveTo(x2,y2);
  image1.Canvas.lineto(x2+z,y2);
  x2 := x2+z;
  Sleep(5);
  z := Random(10)+1;
  image1.canvas.MoveTo(x3,y3);
  image1.Canvas.lineto(x3+z,y3);
  x3 := x3+z;
  Sleep(5);
  z := Random(10)+1;
  image1.canvas.MoveTo(x4,y4);
  image1.Canvas.lineto(x4+z,y4);
  x4 := x4+z;
  Sleep(5);

until (x1 > 500) or (x2 > 500) or (x3 > 500) or (x4 > 500);
wolke
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 240



BeitragVerfasst: Mi 04.05.05 16:55 
du merkst also eine pause von 5 millisekunden? ;)
T1g3r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: Mi 04.05.05 21:20 
ok aber der mach anfags ne lange pause und dann gar keine mehr egal wie hoch ich des mache.
Warum??? :?: :?: :?: :?:
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 04.05.05 21:48 
Da hast du was falsch verstanden. er macht alle änderungen nur eben am ende deiner schleife. wenn du willst, dass deine anwendung auf änderungen reagiert, WÄHREND sie den code ausführt, setze ans ende der schleife ein Application.ProcessMessages; du wirst sehen, das wars auch schon.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Do 05.05.05 06:40 
Hier stehts auch nochmal:

www.delphi-forum.de/...41386&highlight=