| Autor |
Beitrag |
mick
      
Beiträge: 159
|
Verfasst: So 02.01.05 12:41
tino, deine weisung sei mir befehl  :
im forum findet sich fuer einen countdown folgender anscheinend allgemein akzeptierter code:
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: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78:
| type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private public procedure null; end; TMein = class(TThread) procedure Execute; override; procedure doit; end; var Form1: TForm1; implementation {$R *.DFM} var t: TTime; const lauf: boolean = false; n = '00:00:00'; procedure TMein.Execute; begin repeat if lauf then synchronize(doit); until false; end; procedure TMein.doit; var rest: string; begin with Form1 do begin rest := formatdatetime('hh:nn:ss', t - frac(time)); if rest <> label1.caption then label1.caption := rest; if rest = n then begin lauf := false; showmessage('Zeit ist abgelaufen'); end; end; end; procedure TForm1.null; begin label1.caption := n; end; procedure TForm1.FormCreate(Sender: TObject); begin null; button1.caption := '&Start/Stop'; TMein.create(false); end; procedure TForm1.Button1Click(Sender: TObject); var s: string; begin if not lauf then begin s := '01:25:30'; lauf := true; label1.caption := s; t := strtotime(s) + time + 0.00001; end else begin lauf := false; null; end; end |
wie kann ich den modifizieren, so dass ich in einem zusaetzlichen label-/editfeld eine uhr habe, die mir zeitgleich hochzaehlt (quasi eine stoppuhr)?
ciao,
mijozi.
|
|
Danzig.Bln
Hält's aus hier
Beiträge: 8
|
Verfasst: Mi 12.01.05 16:34
ich weiss ja nicht ob es bei delphi 5 genau ist wie bei deiner version .... aber ich hab mal im unterricht ne uhr erstellt , die hat stoppuhr countdown + 2 wecker ...
weiss ja net ob du was damit anfangen kannst ........
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: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Button3: TButton; Edit2: TEdit; Button4: TButton; Label4: TLabel; Label5: TLabel; Edit3: TEdit; Edit4: TEdit; Button5: TButton; Label6: TLabel; Label7: TLabel; Label8: TLabel; Button7: TButton; Edit5: TEdit; Edit6: TEdit; Label9: TLabel; Label10: TLabel; Label11: TLabel; Button9: TButton; Button10: TButton; Button11: TButton; Button12: TButton; Label12: TLabel; Label13: TLabel; Label14: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button10Click(Sender: TObject); procedure Button11Click(Sender: TObject); procedure Button12Click(Sender: TObject); procedure Label1Click(Sender: TObject); procedure Label2Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation var sekunde,stunde,minute,h,m,wm,wh,whh,wmm,x,y,z:integer; abbruch,hold:string; {$R *.DFM} procedure delay; var start,stop:longint; BEGIN start:=GetTickCount; repeat stop:=GetTickCount; Application.ProcessMessages; until (stop - start >= 0); end;
procedure TForm1.Button1Click(Sender: TObject); begin abbruch:='1'; close; end;
procedure TForm1.Button2Click(Sender: TObject); begin repeat for stunde:=0 to 23 do BEGIN for minute:=0 to 59 do BEGIN for sekunde:=0 to 59 do BEGIN if stunde<10 then label1.caption:='0'+inttostr(stunde); if stunde>9 then label1.caption:=inttostr(stunde); if minute<10 then label2.caption:='0'+inttostr(minute); if minute>9 then label2.caption:=inttostr(minute); if sekunde<10 then label3.caption:='0'+inttostr(sekunde); if sekunde>9 then label3.caption:=inttostr(sekunde); if abbruch='1' then halt;
delay;
end; end; end; until sekunde > 89 ; end; procedure TForm1.Button3Click(Sender: TObject); begin h:=strtoint(edit1.text); m:=strtoint(edit2.text); repeat for stunde:=h to 23 do BEGIN h:=0; label1.caption:=inttostr(stunde); for minute:=m to 59 do BEGIN m:=0; label2.caption:=inttostr(minute); if minute=59 then label2.caption:=inttostr(minute); for sekunde:=0 to 59 do BEGIN if stunde<10 then label1.caption:='0'+inttostr(stunde); if stunde>9 then label1.caption:=inttostr(stunde); if minute<10 then label2.caption:='0'+inttostr(minute); if minute>9 then label2.caption:=inttostr(minute); if sekunde<10 then label3.caption:='0'+inttostr(sekunde); if sekunde>9 then label3.caption:=inttostr(sekunde); if abbruch='1' then halt; wm:=strtoint(label7.caption); wh:=strtoint(label6.caption); if (label1.caption = label6.caption) and (label2.caption = label7.caption) then label8.caption:='Biep Biep'; if (minute = (wm+5)) or (minute = (wm-59)) then label8.caption:=''; wmm:=strtoint(label10.caption); whh:=strtoint(label9.caption); if (label1.caption = label9.caption) and (label2.caption = label10.caption) then label11.caption:='Biep Biep'; if (minute = (wmm+5)) or (minute = (wmm-59)) then label11.caption:='';
delay; end; end; end;
until sekunde > 88 ; end;
procedure TForm1.Button4Click(Sender: TObject); begin label1.caption:=edit1.text; label2.caption:=edit2.text; label3.caption:='00';
end; procedure TForm1.Button5Click(Sender: TObject); begin label6.caption:=edit3.text; label6.visible:=true; label7.caption:=edit4.text; label7.visible:=true; end;
procedure TForm1.Button6Click(Sender: TObject); begin label8.caption:=''; end;
procedure TForm1.Button7Click(Sender: TObject); begin label9.caption:=edit5.text; label9.visible:=true; label10.caption:=edit6.text; label10.visible:=true; end;
procedure TForm1.Button8Click(Sender: TObject); begin label11.caption:=''; end;
procedure TForm1.Button9Click(Sender: TObject); begin label6.caption:='25'; label7.caption:='61'; label6.visible:=false; label7.visible:=false; end;
procedure TForm1.Button10Click(Sender: TObject); begin label9.caption:='25'; label10.caption:='61'; label9.visible:=false; label10.visible:=false; end;
procedure delay2; var start,stop:longint; BEGIN start:=GetTickCount; repeat stop:=GetTickCount; Application.ProcessMessages; until (stop - start >= 99999999999999999); end; procedure TForm1.Button11Click(Sender: TObject); begin x:=strtoint(label1.caption); y:=strtoint(label2.caption); z:=strtoint(label3.caption); repeat for stunde:=x to 23 do BEGIN x:=0; label1.caption:=inttostr(stunde); for minute:=y to 59 do BEGIN y:=0; label2.caption:=inttostr(minute); if minute=59 then label2.caption:=inttostr(minute); for sekunde:=z to 59 do BEGIN z:=0; label3.caption:=inttostr(sekunde); if sekunde=59 then label3.caption:=inttostr(sekunde); if stunde<10 then label1.caption:='0'+inttostr(stunde); if stunde>9 then label1.caption:=inttostr(stunde); if minute<10 then label2.caption:='0'+inttostr(minute); if minute>9 then label2.caption:=inttostr(minute); if sekunde<10 then label3.caption:='0'+inttostr(sekunde); if sekunde>9 then label3.caption:=inttostr(sekunde); if abbruch='1' then halt; delay2;
end; end; end; until sekunde > 89 ; end;
procedure TForm1.Button12Click(Sender: TObject); begin x:=strtoint(label1.caption); y:=strtoint(label2.caption); z:=strtoint(label3.caption); repeat for stunde:=x to 23 do BEGIN x:=0; label1.caption:=inttostr(stunde); for minute:=y to 59 do BEGIN y:=0; label2.caption:=inttostr(minute); if minute=59 then label2.caption:=inttostr(minute); for sekunde:=z to 59 do BEGIN z:=0; label3.caption:=inttostr(sekunde); if sekunde=59 then label3.caption:=inttostr(sekunde); if stunde<10 then label1.caption:='0'+inttostr(stunde); if stunde>9 then label1.caption:=inttostr(stunde); if minute<10 then label2.caption:='0'+inttostr(minute); if minute>9 then label2.caption:=inttostr(minute); if sekunde<10 then label3.caption:='0'+inttostr(sekunde); if sekunde>9 then label3.caption:=inttostr(sekunde); if abbruch='1' then halt; delay;
end; end; end; until sekunde > 89 ; end;
procedure TForm1.Label1Click(Sender: TObject); begin label1.caption:=edit1.text; end;
procedure TForm1.Label2Click(Sender: TObject); begin label2.caption:=edit2.text; end;
end. |
ist zwar ein wenig lang ... aber was du nicht brachst , kannste ja weghauen
Moderiert von Christian S.: Delphi-Tags hinzugefügt.
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Mi 12.01.05 16:42
AAAH hau doch bitte den code in [delphi*] Tags rein! also als beispiel:
Delphi-Quelltext 1: 2: 3: 4:
| procedure blahblah; begin showmessage('hihi'); end; |
einfach ein [delphi*] (ohne den *) vor den Code, ein [/delphi*] hinter den code (ohne * natürlich ^^)
_________________ >+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
|
|
Danzig.Bln
Hält's aus hier
Beiträge: 8
|
Verfasst: Mi 12.01.05 16:49
|
|
mick 
      
Beiträge: 159
|
Verfasst: Sa 29.01.05 13:37
erstmal danke!
ciao,
mijozi.
|
|
retnyg
      
Beiträge: 2754
SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
|
Verfasst: Sa 29.01.05 13:54
| JayEff hat folgendes geschrieben: | | AAAH hau doch bitte den code in [delphi*] Tags rein! |
willste auch MOD werden JayEff ? 
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Sa 29.01.05 14:11
klar! gerne! wenn du was arangieren kannst...? 
_________________ >+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
|
|
Gausi
      
Beiträge: 8554
Erhaltene Danke: 481
Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
|
Verfasst: Sa 29.01.05 14:28
 Bitte beim Thema bleiben. Danke. 
_________________ We are, we were and will not be.
|
|
mick 
      
Beiträge: 159
|
Verfasst: Sa 29.01.05 15:50
nun gut, dann hake ich nochmals nach:
wie muesste ich den vor mir oben zitierten code denn modifizieren, um das gewuenschte ergebnis (also eine vorwaerts laufender zaehler) zu bekommen?
ciao,
mijozi.
ps: nebenbei: dass der code oben so "todsicher" laeuft, dass meine gesamte anwendung teils lahmgelegt ist, ist ein weiteres problem. aber dafuer sollte ich wohl anderswo (new topic) nachfragen, oder? ;-)
|
|
|