Autor Beitrag
boozzz
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win XP, Win 2000, SuSe Linux

BeitragVerfasst: Fr 06.01.06 20:42 
Hi,
im folgenden möchte ich Image1 blinken lassen (An-Aus-An-Aus...). Kann mir jemand sagen, wieso das nicht funktioniert?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Image1.Visible:=false;
  sleep(500);
  Form1.Image1.Visible:=true;
  sleep(500);
  Form1.Image1.Visible:=false;
  sleep(500);
  Form1.Image1.Visible:=true;
  sleep(500);
  Form1.Image1.Visible:=false;
  sleep(500);
end;
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 06.01.06 20:52 
Probiers mal So.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Image1.Visible:= not Image1.Visible;
end;
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 06.01.06 20:54 
user profile iconboozzz hat folgendes geschrieben:
Hi,
im folgenden möchte ich Image1 blinken lassen (An-Aus-An-Aus...). Kann mir jemand sagen, wieso das nicht funktioniert?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Image1.Visible:=false;
  sleep(500);
  Form1.Image1.Visible:=true;
  sleep(500);
  Form1.Image1.Visible:=false;
  sleep(500);
  Form1.Image1.Visible:=true;
  sleep(500);
  Form1.Image1.Visible:=false;
  sleep(500);
end;


WAS funktioniert nicht? Es sollte eigendlich funktionieren, obwohl es in einem Timer wesentlich schöner währe :?

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
boozzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win XP, Win 2000, SuSe Linux

BeitragVerfasst: Sa 07.01.06 00:58 
Zitat:
WAS funktioniert nicht? Es sollte eigendlich funktionieren, obwohl es in einem Timer wesentlich schöner währe
Es tut sich nichts, wenn ich auf den Button klicke, nur dass nach ca. 2 Sekunden das Image verschwindet. Blinken tut da nichts.

Blackheart's Möglichkeit funktioniert leider auch nicht. :cry:

Wie könnte ich das mit einem Timer realisieren? :roll: (Bin noch Anfänger in Delphi)
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Sa 07.01.06 01:15 
Mach mal vor jedem Sleep ein Repaint; ;)

greetz


EDIT: Und warum hast du was gegen Timer? Ist doch wesentlich eleganter und während dem blinken schläft das Programm nicht..

EDIT2: Frage überlesen :oops:

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.


Zuletzt bearbeitet von Born-to-Frag am Sa 07.01.06 03:50, insgesamt 1-mal bearbeitet
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Sa 07.01.06 01:38 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 if Image1.Visible = true then
  Image1.Visible := false
 else
  Image1.Visible := true;
end;


Die Geschindigkeit kannst du in Timer1.Interval festlegen (in ms)

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Sa 07.01.06 03:49 
user profile iconCalyptus hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 if Image1.Visible = true then
  Image1.Visible := false
 else
  Image1.Visible := true;
end;


Die Geschindigkeit kannst du in Timer1.Interval festlegen (in ms)


Mhhh Calyptus.. das geht wohl noch eleganter:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 Image1.Visible := not Image1.Visible;
end;


;)

die Alternative zu Sleep.

greetz
-B2F

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 07.01.06 10:46 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
  Form1: TForm1;
  Zaehler:Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Inc(Zaehler); {Mitzählen}
  Timer1.Interval:=500;{Intervall 0,5 sec.}
  if Zaehler=11 then Timer1.Enabled:=false; {5 Mal Blinken lassen dann aus}
  Image1.Visible := not Image1.Visible;
end;
LH_Freak
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 385

Win XP
D7 PE, D2k5 Trial
BeitragVerfasst: So 08.01.06 01:43 
ich würde da lieber

{Zeile 17:} if Zaehler>11 then Timer1.Enabled:=false; {5 Mal Blinken lassen dann aus}

hinmachen
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 08.01.06 01:48 
Ist aber nicht nötig weil 11 höchstwarscheinlich kommt (wenn nichts schiefgeht...)
LH_Freak
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 385

Win XP
D7 PE, D2k5 Trial
BeitragVerfasst: So 08.01.06 02:03 
sicher ist sicher :D
boozzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win XP, Win 2000, SuSe Linux

BeitragVerfasst: So 08.01.06 17:29 
bin gerade beim rumprobieren.
Was soll die Fehlermeldung:
"Datei.pas(407): Undefinierter Bezeichner: 'Repaint'" ??

Repaint ist doch ein Delphi-Befehl, oder? Oder muss ich da wat deklarieren?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: So 08.01.06 17:55 
user profile iconboozzz hat folgendes geschrieben:
bin gerade beim rumprobieren.
Was soll die Fehlermeldung:
"Datei.pas(407): Undefinierter Bezeichner: 'Repaint'" ??

Repaint ist doch ein Delphi-Befehl, oder? Oder muss ich da wat deklarieren?


Zeig mal ein bisschen mehr Code ;)

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
0xCC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 150



BeitragVerfasst: So 08.01.06 18:03 
tu einfach zum sleep ein application.processmessages
boozzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win XP, Win 2000, SuSe Linux

BeitragVerfasst: Mi 11.01.06 20:08 
Die Fehlermeldung beim compilieren kommt leider trotzdem.
0xCC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 150



BeitragVerfasst: Mi 11.01.06 20:38 
das repaint lass weg
Mister X-Ray
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Win XP, Win 2000
D7 Pers, D2005 Pers
BeitragVerfasst: Do 12.01.06 16:43 
du hast hoffentlich

ausblenden Delphi-Quelltext
1:
Image.Repaint;					


und nicht nur

ausblenden Delphi-Quelltext
1:
Repaint;					


oder?

Gruß
Mister X-Ray

_________________
Wissen ist Macht, aber nichts wissen macht nichts !
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 12.01.06 17:40 
user profile iconMister X-Ray hat folgendes geschrieben:
du hast hoffentlich

ausblenden Delphi-Quelltext
1:
Image.Repaint;					


und nicht nur

ausblenden Delphi-Quelltext
1:
Repaint;					


oder?

Gruß
Mister X-Ray


Schwachsinn -.- Repaint allein geht auch, das ist dann nähmlich wie FormX.Repaint und das wird genauso funktieren, da dann alles auf der Form repainted wird ;)

Aber wenn die Fehlermeldung "Unbekannter Bezeichner 'Repaint'" auch kommt wenn du Repaint; weglässt, stimmt da was nicht :lol:

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 12.01.06 17:45 
Also ich weiß nicht was für ein RIESIGES Brett du vorm Kopf hast, aber hier noch mal so wie du es machen sollst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
image1.Visible := not image1.Visible;
repaint;
sleep(500);
image1.Visible := not image1.Visible;
repaint;
sleep(500);
image1.Visible := not image1.Visible;
repaint;
sleep(500);


Und damit du es auch ganz sicher schaffst, hier mal ein Projekt zum testen

greetz

EDIT: Und noch mal als Timer ein Projekt -.- (wesendlich besser, da kann man in der zeit auch noch was machen am prog und es friert nicht ein ;) )

Jetzt sollte es wirklich klar sein, oder?


EDIT2: Du kannst natürlich auch immer statt not auch True bzw. False benutzen, im Timer ist es aber einfacher so, außer du machst es so wie es weiter oben steht:

ausblenden Delphi-Quelltext
1:
2:
3:
if Timer1.Enabled = True then
  Timer1.Enabled := False
else Timer1.Enabled := True;


Das war jetzt aber ausführlich genug..

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Do 12.01.06 20:49 
Hi,

nur um nochmal darauf zurückzukommen warum es mit Sleep nicht geht... ;)
Du gibst dem programm keine chance irgendwo neue Messages zu verarbeiten.. daher pack einfach vor jedes sleep ein Application.ProcessMessages; und schon sollte es gehen (auch ohne repaint)

Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!