ts-soft hat geschrieben:Sag erst mal, was Du damit meinst auf die Gadgets zugreifen und besser mal einen ausführbaren Beispielcode
damit man eine Vorstellung bekommst, was Du da vorhast.
Das überprüfen mit IsGadget usw., sollte man grundsätzlich in Threads und Callbacks machen!
Mit Zugriefen meine ich AddGadgetItem (in eine Liste, die im Thread erstellt wurde)
Da es sich um ein kommerzielles Projekt handelt poste ich nur ungern meinen source. Aber ich hoffe, dass dieser Abschnitt alles soweit klärt
Code: Alles auswählen
Procedure UpdateRoutine(md5handle)
Repeat
in.s = ReadString(md5handle)
If Len(in) > 1
If FindString(in, "[", 0)
relativepath.s = Mid(in, 2, Len(in) -2)
Else
md5sum.s = in
EndIf
Else
UpdateFile(relativepath, md5sum)
count + 1
SetGadgetState(progress, count)
; SetGadgetState(#progress, count)
EndIf
Until Eof(md5handle) <> 0
CloseFile(md5handle)
DeleteFile("md5")
updated = 1
;---Autostartbuttoncode---;
; If GetGadgetState(#autostart) = #PB_Checkbox_Checked
; RunProgram("notepad.exe")
; EndIf
; ProcedureReturn 1
EndProcedure
Procedure Open_main(progressbar_elements)
If OpenWindow(#main, 652, 375, 311, 201, "Notepad Launcher " + version + " Build: "+ Str(#PB_Editor_BuildCount), #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
ButtonGadget(#start, 190, 160, 110, 30, "Starten")
GadgetToolTip(#start, "führt Notepad aus")
CheckBoxGadget(#autostart, 70, 160, 110, 20, "automatisch Starten")
GadgetToolTip(#autostart, "Nach dem Update Notepad automatisch ausführen")
ProgressBarGadget(#progress, 10, 130, 290, 20, 0, progressbar_elements)
ListViewGadget(#list, 10, 10, 290, 110)
If autostart
SetGadgetState(#autostart, #PB_Checkbox_Checked)
EndIf
EndIf
EndProcedure
Procedure mainloop(*dummy)
Open_main(progressbar_elements)
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #start
If updated
RunMMOGrinder()
End
Else
MessageRequester("Bitte warten...", "Bitte warten sie bis der Update-Vorgang beendet ist.")
EndIf
ElseIf GadgetID = #autostart
If GetGadgetState(#autostart) = #PB_Checkbox_Checked And autostart = false
filehandle = OpenFile(#PB_Any ,ini_file)
If filehandle
FileSeek(filehandle, Lof(filehandle))
If IsEntryPresent(filehandle, "[Settings]")
WriteStringN(filehandle, "autostart=true")
; SetGadgetState(#autostart, #PB_Checkbox_Checked)
autostart = true
Else
WriteStringN(filehandle, "")
WriteStringN(filehandle, "[Settings]")
WriteStringN(filehandle, "autostart=true")
; SetGadgetState(#autostart, #PB_Checkbox_Checked)
autostart = true
EndIf
Else
MessageRequester("Fehler", "Fehler beim Speichern, der Datei "+ini_file)
EndIf
CloseFile(filehandle)
ElseIf GetGadgetState(#autostart) = #PB_Checkbox_Unchecked And autostart = true
filehandle = OpenFile(#PB_Any ,ini_file)
If filehandle
FileSeek(filehandle, Lof(filehandle))
If IsEntryPresent(filehandle, "[Settings]")
DeactivateEntry(filehandle, "autostart=")
autostart = false
EndIf
Else
MessageRequester("Fehler", "Fehler beim Speichern, der Datei "+ini_file)
EndIf
CloseFile(filehandle)
EndIf
ElseIf GadgetID = #progress
ElseIf GadgetID = #list
EndIf
EndIf
Delay(50)
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
EndProcedure
;-----MAIN
If CreateThread(@mainloop(), dummy)
Updateroutine(md5_handle)
Else
MessageRequester("Fehler", "Fehler beim erstellen des Threads")
EndIf