Code: Select all
Procedure PerformLogin()
Protected Button_Cancel, Button_Login
If OpenWindow(#Form_Login, #PB_Ignore, #PB_Ignore, 300, 150, " " + VersionInfo\ProductName + " - " + Language("Main", "LogInCaption"), #PB_Window_Tool | #PB_Window_ScreenCentered)
ActiveSubWindowCount + 1
Macros::FontStyleNormal
;
String_Username = StringGadget(#PB_Any, 150, 30, 110, 20, "")
String_Password = StringGadget(#PB_Any, 150, 70, 110, 20, "", #PB_String_Password)
TextGadget(#PB_Any, 50, 30, 90, 20, Language("Main", "UserName"), #PB_Text_Right)
TextGadget(#PB_Any, 50, 70, 90, 20, Language("Main", "Password"), #PB_Text_Right)
Button_Cancel = ButtonGadget(#PB_Any, 80, 110, 85, 25, Language("Shared", "Cancel")): GadgetToolTip(Button_Cancel, Language("Main", "HintCancel"))
Button_Login = ButtonGadget(#PB_Any, 175, 110, 85, 25, Language("Main", "LogIn")): GadgetToolTip(Button_Login, Language("Main", "HintLogin"))
EndIf
StickyWindow(#Form_Login, #True)
SetActiveGadget(String_Username)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
ActiveSubWindowCount - 1
CloseWindow(#Form_Login)
Break
Case #PB_Event_Gadget
If EventGadget() = Button_Cancel
ActiveSubWindowCount - 1
LoggedIn = #False
CloseWindow(#Form_Login)
Break
ElseIf EventGadget() = Button_Login
LoggedIn = AttemptLogin()
If LoggedIn
ActiveSubWindowCount - 1
CloseWindow(#Form_Login)
Break
EndIf
EndIf
EndSelect
ForEver
EndProcedure