Autor Beitrag
Finger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Do 13.04.06 09:48 
Hallo ich wollte ma fragen (da ich nicht weiss in welche Kategorie frage ich hier) ob es einen Befehl gibt um zu warten! Also das man sagt wait.1 oder so das es eine sekunde wartet bevor es weiterfährt im Programm!
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 13.04.06 09:51 
ausblenden Delphi-Quelltext
1:
sleep(millisekunden);					
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 13.04.06 09:59 
Die Funktion dafür heisst sleep und erwartet die Zeit in Millisekunden. Die hat allerdings den Nachteil, dass das Programm während der Wartezeit wirklich nichts macht, d.h. Fenster werden nicht neu gezeichnet, sind nicht verschiebbar usw.
Eine bessere Lösung ist meistens, in einer Schleife zu warten, die regelmässig Application.ProcessMessages aufruft, dann macht das Programm nicht den Eindruck, als hätte es sich aufgehängt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
startTime := GetTickCount;
while GetTickCount < startTime + 1000 do
begin
  sleep(100);
  Application.ProcessMessages;
end;


Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
nullplan001
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win 2000 Professional, Debian Linux 4.0 (Etch,Stable)
Pascal (FreePascal 2.0.2, TurboPascal 7.0), C(++) (G++/GCC 3.4.2 + MinGW), Java (JDK 1.5.0_07), PHP (PHP 5.1.4)
BeitragVerfasst: Do 13.04.06 10:50 
Hi all,
zu TurboPascal-Zeiten hieß das Ding delay, war aber genauso zu bedienen:
ausblenden Delphi-Quelltext
1:
2:
3:
//mach was und warte mal kurz;
delay(1); //Wirklich ganz kurz;
//mach was anderes

Tschö,
nullplan

_________________
Ich fahr' nicht selber, weil ich festgestellt habe: ich fahre zu emotional. Bin 180 gefahren wo 30 erlaubt war... -- Jürgen von der Lippe
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 13.04.06 11:42 
hm delay kennt er nicht, hab delphi 7 ?!?
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 13.04.06 11:45 
user profile iconnullplan001 hat folgendes geschrieben:
Hi all,
zu TurboPascal-Zeiten hieß das Ding delay


weiter oben steht doch der richtige befehl:

ausblenden Delphi-Quelltext
1:
sleep(50); //mit angabe in millisekunden...					
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 13.04.06 11:46 
oh, ok danke :o)
Finger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Do 13.04.06 12:54 
[highlight]startTime := GetTickCount;
while GetTickCount < startTime + 1000 do
begin
sleep(100);
Application.ProcessMessages;
end;[/highlight]

Wie muss ich denn den Einbauen? Ich weiss nicht genau wie?
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 13.04.06 12:59 
du setzte den code einfach genau an die stelle wo eine pause gemacht werden soll. vergiss aber nicht starttime als variable zu deklarieren.
Finger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Do 13.04.06 13:04 
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:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
procedure TForm1.testknopfClick(Sender: TObject);

var a, b, i, starttime:integer;

begin



Listbox1.Clear  ;

a:=strtoint(eingabe.Text);
b:=Strtoint(schluss.Text);

if a > b then
begin
form3.show      ;
eingabe.text:= '' ;
schluss.text:= ''  ;
end
else begin

 if a > b then begin  //Zahlendreher korrigieren
    i := a;
    a := b;
    b := i;
  end;

Progressbar1.Position := 0;
Progressbar1.Max := abs(b-a);
Progressbar1.Step := 1;

Listbox1.items.Clear;
  for i := a to b do begin
    startTime := GetTickCount;
while GetTickCount < startTime + 100 do
begin
  sleep(100);
  Application.ProcessMessages;
end;
    Progressbar1.StepIt;
  end;

repeat

ListBox1.Items.Add(IntToStr(a));

a:=a+1;





until a>b;
Progressbar1.Position := 0;
eingabe.text:= ''     ;
schluss.text:= ''      ;



end;


Es geht! Aber jetzt ist der Progress bar auch nach abgeschlossener ausrechnung noch am laufen!!! was kann ich dagegen tun!
Hab herausgefunden das die bar korrekt funktioniert wenn ich 0 sleep gebe! ansonsten füllt sie sich und das programm ist nicht mehr zu beenden!
NCortex
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 126

WIN 2000
D7 Enterprise
BeitragVerfasst: Sa 27.01.07 03:38 
was hälts du davon, einfach die schrittweite selbst zu berechnen und Progressbar.position selbst zuzuzweien?

_________________
"...by all means, do not use a hammer." (aus einer IBM Technikerdokumentation ca. 1920)
--->außer es kam von Microsoft<---
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 27.01.07 03:47 
tja, finger biste schon weiter??? falls ja, was hälst du davon den thread auf beantwortet zu setzen?