Wenn ein Fehler auftritt, steht der Fehler direkt in der Zwischenablage
und kann hier eingefügt werden.
Code: Alles auswählen
IncludePath "..\src\"
IncludeFile "EProxy.pb"
DisableExplicit
Procedure$ FormatBytes(Bytes.q)
Protected FBytes$
If Bytes <= 768
FBytes$ = Str(Bytes) + " Bytes"
ElseIf Bytes <= 768*1024
FBytes$ = StrD(Bytes / 1024, 2) + " KB"
ElseIf Bytes <= 768*1024*1024
FBytes$ = StrD(Bytes / (1024*1024), 2) + " MB"
Else
FBytes$ = StrD(Bytes / (1024*1024*1024), 2) + " GB"
EndIf
ProcedureReturn FBytes$
EndProcedure
Procedure ErrorHandler()
Protected error$
error$ = GetFilePart(ErrorFile()) + ": " + Str(ErrorLine()) + ": " + ErrorMessage()
SetClipboardText(error$)
MessageRequester("Error", error$)
EndProcedure
OnErrorCall(@ErrorHandler())
If InitNetwork() = 0
MessageRequester("Proxy", "InitNetwork, fehlgeschlagen!")
End
EndIf
OpenWindow(#Null, 0, 0, 210, 105, "ProxyTest", #PB_Window_ScreenCentered | #PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
StickyWindow(#Null, 1)
Button = ButtonGadget(#PB_Any, 5, 5, 200, 20, "Start Proxy")
String = StringGadget(#PB_Any, 5, 30, 200, 20, "8080", #PB_String_Numeric)
Text = TextGadget(#PB_Any, 5, 55, 200, 20, "", #PB_Text_Center | #PB_Text_Border)
Text2 = TextGadget(#PB_Any, 5, 80, 200, 20, "", #PB_Text_Center | #PB_Text_Border)
Repeat
Event = WaitWindowEvent(100)
If Event = #PB_Event_Gadget
If EventGadget() = Button
If Proxy
EProxy_DeInit(Proxy)
Proxy = #Null
Else
Proxy = EProxy_Init(Val(GetGadgetText(String)))
EndIf
If Proxy
SetGadgetText(Button, "Stop Proxy")
DisableGadget(String, #True)
Else
SetGadgetText(Button, "Start Proxy")
DisableGadget(String, #False)
EndIf
EndIf
EndIf
If Proxy
SetGadgetText(Text, "D: " + FormatBytes(EProxy_TotalDownloadedBytes(Proxy)) + "; U: " + FormatBytes(EProxy_TotalUploadedBytes(Proxy)) + "; C: " + Str(EProxy_TotalConnections(Proxy)))
SetGadgetText(Text2, "D: " + FormatBytes(EProxy_CurrentDownloadRate(Proxy)) + "/s; U: " + FormatBytes(EProxy_CurrentUploadRate(Proxy)) + "/s")
EndIf
Until Event = #PB_Event_CloseWindow
If Proxy
EProxy_DeInit(Proxy)
EndIf
End