Autor Beitrag
chickenfigt1989
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 19:21 
Hallo
Bei folgenden Code wird der Sound immer von neu gestartet weis einer wieso?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Timer6Timer(Sender: TObject);
begin
Label2.visible:=true;
if sound < StrtoTime('00:00:01'then
    SndPlaySound( 'lachen.WAV', SND_ASYNC )
   else
    begin
      sound:=sound - 1 / SecsPerDay;
end;


lg
Metschu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

Windows XP SP2 Home
Delphi 7; Delphi XE2-Starter
BeitragVerfasst: So 14.08.11 20:00 
Warscheinlich weil Timer 6 immer noch weiter läuft und "if sound < StrtoTime('00:00:01')" immer noch "true" ergibt?
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 21:22 
ok und wie stopp ich den timer dann sobald er bei 00:00:01 ist?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.08.11 21:31 
Ein Timer hat doch nun wirklich nicht viele Eigenschaften... wie wäre es mit Enabled?
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 21:37 
Ja das ist mir klar aber wenn ich das folgender maße mach:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
Label2.visible:=true;
if sound < StrtoTime('00:00:01'then
    SndPlaySound( 'schaf.WAV', SND_ASYNC )
Timer6.enabled:=false
   else
    begin
      sound:=sound - 1 / SecsPerDay



Dann meckert er immer rum
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.08.11 21:38 
:roll:
Ich rücke mal richtig ein...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  Label2.visible:=true;
  if sound < StrtoTime('00:00:01'then
    SndPlaySound( 'schaf.WAV', SND_ASYNC )

  Timer6.enabled:=false
  else
  begin
    sound:=sound - 1 / SecsPerDay
Jetzt deutlich genug?

Und dass da ein Semikolon fehlt, sagt dir Delphi doch wohl schon direkt, oder?
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 22:49 
Ok habs gecheckt vielen Dank.
Nun ne andere Frage:

Kann ich bei diesen Code hier die Uhrzeit aus der Ini datei holen?

ausblenden Delphi-Quelltext
1:
Zeit:= StrtoTime('00:00:05');					
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.08.11 22:50 
Woher der String kommt, ist doch egal...
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 23:00 
Wieso sagt er mir hier dann

ausblenden Quelltext
1:
[Error] Unit1.pas(70): Incompatible types: 'TDateTime' and 'String'					


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
var
  ini: TIniFile;
  filename: String;
begin
UrlDownloadtofile(nil,PChar('http://www.farm-house.de/shaun/einstellungen.ini'),PChar(ExtractFilePath(Application.Exename) + 'einstellungen.ini'),0,nil);
filename := ExtractFilePath(ParamStr(0)) + 'einstellungen.ini';
  ini := TIniFile.Create(filename);
Zeit:=ini.ReadString('Zeit','Zeit1','');
time:= StrtoTime('00:00:05');



Nachtrag://

ausblenden Delphi-Quelltext
1:
Zeit:=StrtoTime(ini.ReadString('Zeit','Zeit1',''));					


Oh mann habs doch geschnallt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.08.11 23:05 
Weil du Zeit als TDateTime deklarierst hast und versuchst einen String aus der Ini zuzuweisen.

// EDIT:
Ja, genau. ;-)
:zustimm:
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 14.08.11 23:06 
Hab Oben Editiert und es Klappt Wunderbar.

Siehste bin doch Lernwillig :)
DonManfred
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 148
Erhaltene Danke: 2

Windows 7
Delphi XE3 Pro + HTML5Builder
BeitragVerfasst: Di 16.08.11 09:57 
OffTopic:

Willig mag stimmen. Fähig eher nicht.

_________________
Gruss Manfred

Für diesen Beitrag haben gedankt: Tintenblut