Autor Beitrag
Thunder00
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Fr 24.01.03 17:10 
Hallo,

Ich suche seit längerem ne Möglichkeit, eine Pause in den Code einzufügen, wo Delphi dann eine bestimmte Zeit wartet, bis es weitergeht.

Da habe cih den befehl sleep gefunden.
Leider funktioniert der nie so wie ich das will. hier ist mein zurzeitiges problem:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Edit1Click(Sender: TObject);
begin
  If Edit1.Enabled = False then
  begin
    Button1.Font.Color := clRed;
    sleep(900);
    Button1.Font.Color := clWindowText;
    Button2.Font.Color := clRed;
    sleep(900);
    Button1.Font.Color := clRed;
    Button2.Font.Color := clWindowText;
  end;
end;


Ich will, das wenn auf ein TEdit geklickt wird, das 2 buttons "flashen". Also die schrift quasi aufleuchtet. das hab ich so geregelt, das ich die farbe verändere...aber das geht net...

Bitte helft mir...
Der wartet immer nur ne kurze zeit ab, in der zeit passiert aber nix.

Vielen Dank im VOraus

_________________
If you can't make it good, at least make it looks good. (Bill Gates)
hansg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: Fr 24.01.03 17:13 
Hallo,

versuche es doch mal dem Timer.

Gruß Hans
Thunder00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Fr 24.01.03 17:43 
Hallo,

Mit dem Timer kann ich aber nur Sekunden-genau...ich brauch aber am besten Milisekunden, weil Sekunden zu lang sind...

_________________
If you can't make it good, at least make it looks good. (Bill Gates)
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Fr 24.01.03 18:14 
Hi,
mach daraus mal das hier:

ausblenden 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:
procedure Delay(time:Integer);
var
  i: integer;
begin
  for i := 0 to time do
  begin
    Application.ProcessMessages;
    Sleep(1);
  end;
end;

procedure TForm1.Edit1Click(Sender: TObject);
begin
  If Edit1.Enabled = False then
  begin
    Button1.Font.Color := clRed;
    delay(900);
    Button1.Font.Color := clWindowText;
    delay(900);
    Button1.Font.Color := clRed;
    delay(900);
    Button2.Font.Color := clWindowText;
  end;
end;
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 24.01.03 18:25 
Thunder00 hat folgendes geschrieben:
Hallo,

Mit dem Timer kann ich aber nur Sekunden-genau...ich brauch aber am besten Milisekunden, weil Sekunden zu lang sind...


Wie kommst du drauf, daß Timer nur Sekundengenau ist. Du kannst auch 1/1000 Sekunden einstellen.

Zurück zu Sleep. Setzt vor Sleep

ausblenden Quelltext
1:
Application.ProcessMessages;					


ein. Dann wird es auch funktionieren.

Allerdings ist die Sleep Geschichte sowieso Blödsinn. In der Zeit ist der Button blockiert. Wenn, dann würde ich eine Timervariante erstellen.
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 26.01.03 00:16 
Also ich nutze für sowas immer ein Timer.
Dort habe ich eine variable die ich hochzähle und per if abfrage wenn es soweit ist das der die nächste zeiele gestart werden kann;)

den timer habe ich hier bei auf INterval= 1

MFG
Michael Springwald