Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 17.05.06 23:01 
Ich probier jetzt schon ne Weile rum aber es klappt einfach nicht. Kann mir einer mal ganz von vorn erklären wie ich Timer erstellen kann?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 17.05.06 23:25 

_________________
There are 10 types of people - those who understand binary and those who don´t.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 18.05.06 06:27 
PS: Hier gibt es eine Suche, die ergibt bei "Timer erstellen" 82 Ergebnisse und da ist nichts dabei gewesen :cry:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Do 18.05.06 06:43 
tja, also das einfachste is:

nim bei system (bei den kompos oben) die kompo mit der uhr als zeichen (TTimer) und zieh sie aufs Formular. bei interval stellts du den zeitabstand in milisekunden an, und wenn du dopelt auf den timer klickst hast du das onclick eriegnis in dem du dann drauflos progammierst.

mfG Green
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 09:31 
frage von mir was willst du mit dem timer anstellen?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Do 18.05.06 10:05 
ausbesserung von green: es ist nicht das onclick ereignis sondern das ontimer ereigniss: tritt bei jedem interval auf!

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 10:50 
hi ich hab mal 2 verschiedene timer hoffe das hilft dir etwas

ausblenden 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:
procedure TStartseite.Label2Click(Sender: TObject);
begin
{ladebalken  }
timer1.Enabled:=true; // timer startet
ladebalken.visible:=true;//balken sichtbar
end;


procedure TStartseite.Timer1Timer(Sender: TObject);
begin
{ladebalken}
IF ladebalken.position=ladebalken.Max then
   begin
    Startseite.hide;        //in Hintergrung schieben
    Hauptmenue.show;        // Form öffnen
    ladebalken.visible:=false;     //ladebalken verschwindet
    ladebalken.position:=ladebalken.Min;
    timer1.Enabled:=false;
    timer2.Enabled:=true;
   end
     else
       ladebalken.position:=ladebalken.position +2;
end;



ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
//label ändert sich bei dem label durch timer2

procedure TStartseite.Timer2Timer(Sender: TObject);
begin
inc(zaehler);
   Timer2.Interval:=600;

  If label4.font.Color=clred then     //farb wechsel
     label4.Font.color:=clmaroon
      else
        label4.font.color:=clred;    //fängt wieder oben an
end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 10:51 
Ja soweit weiß ich auch bescheid, aber wie kann ich den Timer innerhalb einer Schleife einbinden?

Z.B. will ich bei dieser Schleife, dass Delphi 1000ms wartet, bevor es Z einen neuen Zufallswert gibt. Wie erreiche ich das?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
randomize;

repeat
begin
inc(i);
{warte 1000ms > wie?}
z:=random(20+1);

if z > 10 then
panel1.caption:='>10';

if z <= 10 then
panel1.caption:='<=10';
end;

until i > 100;
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 11:06 
hi
ich hab da sowas in der art

also er schreibt eine zahl alle x sekunden in ein edit.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Timer1Timer(Sender: TObject);
var
z:integer;
begin
inc(z);
   Timer1.Interval:=2000;

randomize;
Z:=Random(20);
edit1.text:=floattostr(z);

if z<10 then
panel1.caption:=floattostr(45);

end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 11:10 
Wie soll ich den Timer denn dann starten? Das Timer-Icon ist ja bekanntlich im fertigen Program nicht sichtbar...
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 11:16 
sorry das hab ich vergessen reinzustellen

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:
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Enabled:=false; // timer aus
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true; //timer startet
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
z:integer;
begin  
inc(z);
   Timer1.Interval:=2000;  


randomize;
Z:=Random(11);//zahl von 0-10
edit1.text:=floattostr(z);


if z<10 then
panel1.caption:=floattostr(00); 

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
panel1.Caption:='';//panel ist leer
end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 11:19 
Ok, das werd ich dann nach der Schule gleich mal ausprobieren... Danke bis hierher! :)
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 11:21 
bitte

hab noch ne verbesserte Version
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:
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Enabled:=false; // timer aus
edit1.clear;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true; //timer startet
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
z:integer;
begin
inc(z);
   Timer1.Interval:=2000;


randomize;
Z:=Random(11);
edit1.text:=floattostr(z);


if z<5 then
panel1.caption:='zahl kleiner 5' //zahl kleiner 5

else                  //dann
panel1.caption:=''    //panel leer

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
panel1.Caption:='';    //panel leeren
timer1.enabled:=false;      //timer zurücketzen
edit1.clear;
end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 13:42 
Habs jetzt hinbekommen.. Danke!

PS: Die Erklärungen im Quelltext wären nich nötig gewesen.. ;)

Habs jetzt so gemacht:

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:
procedure TForm1.Button1Click(Sender: TObject);
begin
if not timer1.enabled then
begin
timer1.Enabled:=true;
end
else
begin
timer1.Enabled:=false;
panel1.caption:='angehalten';
end;

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var z,i:integer;
begin
timer1.Interval:=1000;
randomize;

repeat
begin
z:=random(20+1);

if z > 10 then
panel1.caption:='>10';

if z <= 10 then
panel1.caption:='<=10';
end;
until i > 100;

end;
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 13:48 
wieso so kompliziert?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Button1Click(Sender: TObject);  
begin  
if not timer1.enabled then  
begin  
timer1.Enabled:=true;  
end  
else  
begin  
timer1.Enabled:=false;  
panel1.caption:='angehalten';  
end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 14:31 
Das ist ne rein optische Sache... ^^

Dieser Quellcode diente nur als Beispiel, um mir Timer verständlich machen zu können. Ich werde ihn in dieser Form also nicht einsetzen, jetzt kann ich mich an komplexere Sachen mit Timern wagen.. :)
Und wie es kommen muss, hab ich schon das nächste kleine Problem was ich leider nicht verstehe...

Ich will innerhalb eines Timers einen zweiten Timer einsetzen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Interval:=2000;

for b:=1 to 10 do
begin
Timer2.Enabled:=true;
image1.Top:=image1.Top+1;
end;

Timer2.enabled:=false;

end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
Timer2.Interval:=200;
end;


Wenn ich das ganze ausführe, geht das Bild gleich 10Pixel aufeinmal nach unten. Dabei sollte es doch eigentlich nach jedem Pixel ne Pause von 200ms machen, oder?
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 18.05.06 17:45 
Is gut, ich habs hinbekommen...
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Do 18.05.06 17:55 
user profile iconelundril hat folgendes geschrieben:
ausbesserung von green: es ist nicht das onclick ereignis sondern das ontimer ereigniss: tritt bei jedem interval auf!


hab mich nur vertippt ^^ sollte ontimer heissen, war einfach n bissel zu früh am morgen ...