
Oder zu schnell...
Also bei mir geht es, aber Bekannte sagen, dass die Zeitanzeige RAST.
Gr33tz
Der Marc
P.S.:Bitte keine Diskussuion wie unpräzise Delays bei Zeitanzeigen sind..es soll ja nurn "ungenaues Tools" sein

Code: Alles auswählen
;- Window Constants
;
OpenLibrary(0,"user32.dll")
Global Ueberschrift.s
Ueberschrift = "Marc`s Sleep-Timer V1.3"
Enumeration
#Window_0
#Window_1
EndEnumeration
;- Gadget Constants
;
Enumeration
#Text_0
#String_0
#String_1
#Text_1
#Text_2
#Button_0
#CheckBox_1
#CheckBox_2
#String_2
#Text_3
#Button_1
#Button_2
#Text_4
#Button_3
#Text_6
#Text_7
#Text_5
#Image_1
EndEnumeration
;- Fonts
;
Global FontID1
FontID1 = LoadFont(1, "Comic Sans MS", 16, #PB_Font_Bold)
Global FontID3
FontID3 = LoadFont(4, "Arial", 12, #PB_Font_Bold)
Global FontID4
FontID4 = LoadFont(2, "Arial", 12)
Global FontID5
FontID5 = LoadFont(3, "Arial", 11)
UseJPEGImageDecoder()
LoadImage(1,"D:\Images.gif")
Global Image0
;- Catch Images
Image0 = CatchImage(0, ?Image0)
;- Images
DataSection
Image0:
IncludeBinary "Noten.bmp"
EndDataSection
Procedure CheckChars()
For I=1 To Len(GetGadgetText(#String_0))
If Mid(GetGadgetText(#String_0),I,1) = "1" Or Mid(GetGadgetText(#String_0),I,1) = "2" Or Mid(GetGadgetText(#String_0),I,1) = "3" Or Mid(GetGadgetText(#String_0),I,1) = "4" Or Mid(GetGadgetText(#String_0),I,1) = "5" Or Mid(GetGadgetText(#String_0),I,1) = "6" Or Mid(GetGadgetText(#String_0),I,1) = "7" Or Mid(GetGadgetText(#String_0),I,1) = "8" Or Mid(GetGadgetText(#String_0),I,1) = "9" Or Mid(GetGadgetText(#String_0),I,1) = "0" Or Mid(GetGadgetText(#String_0),I,1) = ""
Else
MessageRequester("Fehler:","Die Eingabefelder dürfen keine Zeichen ausser Zahlen enthalten")
SetGadgetText(#String_0,"")
Goto Anfang
EndIf
Next
For I=1 To Len(GetGadgetText(#String_1))
If Mid(GetGadgetText(#String_1),I,1) = "1" Or Mid(GetGadgetText(#String_1),I,1) = "2" Or Mid(GetGadgetText(#String_1),I,1) = "3" Or Mid(GetGadgetText(#String_1),I,1) = "4" Or Mid(GetGadgetText(#String_1),I,1) = "5" Or Mid(GetGadgetText(#String_1),I,1) = "6" Or Mid(GetGadgetText(#String_1),I,1) = "7" Or Mid(GetGadgetText(#String_1),I,1) = "8" Or Mid(GetGadgetText(#String_1),I,1) = "9" Or Mid(GetGadgetText(#String_1),I,1) = "0" Or Mid(GetGadgetText(#String_1),I,1) = ""
Else
MessageRequester("Fehler:","Die Eingabefelder dürfen keine Zeichen ausser Zahlen enthalten")
SetGadgetText(#String_1,"")
Goto Anfang
EndIf
Next
For I=1 To Len(GetGadgetText(#String_2))
If Mid(GetGadgetText(#String_2),I,1) = "1" Or Mid(GetGadgetText(#String_2),I,1) = "2" Or Mid(GetGadgetText(#String_2),I,1) = "3" Or Mid(GetGadgetText(#String_2),I,1) = "4" Or Mid(GetGadgetText(#String_2),I,1) = "5" Or Mid(GetGadgetText(#String_2),I,1) = "6" Or Mid(GetGadgetText(#String_2),I,1) = "7" Or Mid(GetGadgetText(#String_2),I,1) = "8" Or Mid(GetGadgetText(#String_2),I,1) = "9" Or Mid(GetGadgetText(#String_2),I,1) = "0" Or Mid(GetGadgetText(#String_2),I,1) = ""
Else
MessageRequester("Fehler:","Die Eingabefelder dürfen keine Zeichen ausser Zahlen enthalten")
SetGadgetText(#String_2,"")
Goto Anfang
EndIf
Next
Repeat
If Val(GetGadgetText(#String_2)) > 60
Minutes = Minutes + 1
Str.l = Val(GetGadgetText(#String_2)) - 60
SetGadgetText(#String_2,Str(Str))
EndIf
Until Val(GetGadgetText(#String_2)) < 60
Str = Val(GetGadgetText(#String_1))
Str = Str + Minutes
SetGadgetText(#String_1,Str(Str))
Repeat
If Val(GetGadgetText(#String_1)) >60
Hours = Hours + 1
Str = Val(GetGadgetText(#String_1)) - 60
SetGadgetText(#String_1,Str(Str))
EndIf
Until Val(GetGadgetText(#String_1)) < 60
Str = Val(GetGadgetText(#String_0))
Str = Str + Hours
SetGadgetText(#String_0,Str(Str))
EndProcedure
Procedure Reset()
SetGadgetText(#String_0,"0")
SetGadgetText(#String_1,"0")
SetGadgetText(#String_2,"0")
SetGadgetText(#Button_0,"Go")
DisableGadget(#CheckBox_1,0)
DisableGadget(#CheckBox_2,0)
DisableGadget(#Button_0,0)
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 400, 200, 265, 242, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_MinimizeGadget, Ueberschrift)
If CreateGadgetList(WindowID())
TextGadget(#Text_0, 50, 30, 150, 30, "Sleep - Timer")
SetGadgetFont(#Text_0, FontID1)
StringGadget(#String_0, 10, 100, 70, 30, "")
GadgetToolTip(#String_0, "Hier die Stunden eingeben...")
SetGadgetFont(#String_0, FontID1)
StringGadget(#String_1, 100, 100, 70, 30, "")
GadgetToolTip(#String_1, "Hier die Minuten eintragen...")
SetGadgetFont(#String_1, FontID1)
TextGadget(#Text_1, 10, 70, 50, 20, "Stunden:")
TextGadget(#Text_2, 100, 70, 50, 20, "Minuten:")
ButtonGadget(#Button_0, 100, 160, 70, 30, "Go")
CheckBoxGadget(#CheckBox_1, 20, 210, 65, 30, "Signalton")
CheckBoxGadget(#CheckBox_2, 150, 210, 90, 30, "Herunterfahren")
StringGadget(#String_2, 190, 100, 70, 30, "")
GadgetToolTip(#String_2, "Hier bitte die Sekunden eingeben...")
TextGadget(#Text_3, 190, 70, 60, 20, "Sekunden:")
SetGadgetFont(#String_2, FontID1)
EndIf
EndIf
EndProcedure
Procedure Open_Window_1()
If OpenWindow(#Window_1, 390, 260, 280, 100, #PB_Window_TitleBar , "Signal-Fenster")
If CreateGadgetList(WindowID())
ButtonGadget(#Button_1, 30, 60, 130, 30, "Abbrechen")
TextGadget(#Text_6, 50, 20, 90, 40, "Signal...")
SetGadgetFont(#Text_6, FontID1)
ImageGadget(#Image_1, 190, 20, 73, 51, Image0)
EndIf
EndIf
EndProcedure
Open_Window_0()
Anfang:
SetGadgetText(#String_0,"0")
SetGadgetText(#String_1,"0")
SetGadgetText(#String_2,"0")
SetGadgetText(#Button_0,"Go")
DisableGadget(#CheckBox_1,0)
DisableGadget(#CheckBox_2,0)
Repeat
EventID = WaitWindowEvent()
If GetGadgetState(#CheckBox_1) = 1 And check <> 1
Soundfile.s = OpenFileRequester("Soundfile","C:\","Soundfiles|*.wav; *.mp3; *.wma; *.mid; .*midi",0)
check = 1
EndIf
If Soundfile.s = ""
SetGadgetState(#CheckBox_1,0)
ElseIf check = 1
EndIf
If check = 1 And GetGadgetState(#CheckBox_1) = 0
check = 0
EndIf
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #PB_Event_Gadget
If EventGadgetID() = #Button_0
CheckChars()
SetGadgetText(#Button_0,"Abbrechen")
Stunden.l = Val(GetGadgetText(#String_0))
Minuten.l = Val(GetGadgetText(#String_1))
Sekunden.l = Val(GetGadgetText(#String_2))
SetGadgetText(#Button_0,"Abbrechen")
If GetGadgetState(#CheckBox_2) = 1
Shutdowns.s = "Shutdown"
EndIf
Repeat
DisableGadget(#CheckBox_1,1)
DisableGadget(#CheckBox_2,1)
EventID = WindowEvent()
If EventID = 5 Or Title = 1
Ueberschrift = Str(Stunden) + " Stunden " + Str(Minuten) + " Minuten " + Str(Sekunden) + " Sekunden"
SetWindowTitle(#Window_0,Ueberschrift.s)
Title = 1
EndIf
If EventID = 15
Ueberschrift = "Marc`s Sleep-Timer V1.3"
SetWindowTitle(#Window_0,Ueberschrift.s)
Title = 0
EndIf
If EventID = #PB_Event_Gadget
If EventGadgetID() = #Button_0
Antwort = MessageRequester("Bestätigung","Wollen Sie den Countdown abbrechen?",#PB_MessageRequester_YesNo)
If Antwort = 6
SetGadgetText(#String_0,"0")
SetGadgetText(#String_1,"0")
SetGadgetText(#String_2,"0")
Goto Anfang
EndIf
EndIf
If EventGadgetID() = #PB_Event_CloseWindow
Antwort = MessageRequester("Bestätigung","Wollen Sie den Countdown abbrechen und das Programm schliessen?",#PB_MessageRequester_YesNo)
If Antwort = 6
SetGadgetText(#String_0,"0")
SetGadgetText(#String_1,"0")
SetGadgetText(#String_2,"0")
Quit = 1
Goto Ende
EndIf
EndIf
EndIf
If Delay = 0
Sekunden = Sekunden - 1
If Sekunden = -1 And Minuten <> 0
Minuten = Minuten - 1
Sekunden = 59
EndIf
If Sekunden = -1 And Minuten = 0 And Stunden <> 0
Stunden = Stunden - 1
Minuten = 59
Sekunden = 59
EndIf
SetGadgetText(#String_0,Str(Stunden))
SetGadgetText(#String_1,Str(Minuten))
SetGadgetText(#String_2,Str(Sekunden))
Delay = 1000
Else
Delay = Delay - 1
EndIf
Delay(1)
Until Sekunden = <0 And Minuten = 0 And Stunden = 0
SetWindowTitle(#Window_0,"Marc`s Sleep-Timer V1.3")
If check = 1
SetGadgetText(#Button_0,"Go")
DisableGadget(#Button_0,1)
MCI_Load(1,Soundfile)
laenge = MCI_GetLength(1)
MCI_Play(1)
Open_Window_1()
Delay = 0
Volume.f = 0
Repeat
EventID = WindowEvent()
Delay(1)
Delay + 1
If Delay = 100
laenge = laenge - 100
Delay = 0
EndIf
If Volume <> 1000
Volume = Volume + 0.25
MCI_SetVolume(1,Volume)
EndIf
Until laenge < 0 Or EventGadgetID() = #Button_1
If EventGadgetID() = #Button_1
abbruch = 1
EndIf
MCI_Stop(1)
CloseWindow(#Window_1)
MCI_Free(1)
Reset()
If GetGadgetState(#CheckBox_2) = 1 And abbruch <> 1
RunProgram("c:/windows/system32/tsshutdn","0 /Delay:0 /Powerdown","",2)
Quit =1
Goto Ende
SetGadgetText(#Button_0,"Go")
DisableGadget(#Button_0,0)
Else
abbruch = 0
EndIf
check = 0
SetGadgetState(#CheckBox_1,0)
ElseIf check = 0 And GetGadgetState(#CheckBox_2) <> 0
RunProgram("c:/windows/system32/tsshutdn","0 /Delay:0 /Powerdown","",2)
Quit =1
Goto Ende
Else
Reset()
EndIf
EndIf
EndIf
Delay = 100
Ende:
Until Quit = 1