
Code : Tout sélectionner
;- Enumerations
Enumeration
#Win_Login
EndEnumeration
Enumeration
#Btn_No
#Btn_Ok
#Str_Login
#Str_Pass
#Txt_Message
#Txt_Login
#Txt_Password
EndEnumeration
;- Constantes LoginRequester_Ex
#PB_Button_Valid = 32 ; Bouton Valider
#PB_Button_Cancel = 128 ; Bouton Annuler
;- Structures
Structure LOGIN
Login.s
Pass.s
EndStructure
;- Constantes possibles pour l'alignement du message (Constantes du TextGadget)
; #PB_Text_Center
; #PB_Text_Right
;- Types de boutons possibles.
; #PB_Button_Valid
; #PB_Button_Cancel
;- Procedure
Procedure LoginRequester_Ex(Titre.s, MsgClient.s, Type, TextAlignment.l)
Global Log.LOGIN
hWinForeGround = GetForegroundWindow_()
NbLines = CountString(MsgClient, Chr(10))
hText = 15 * (NbLines+1)
If Type & #PB_Button_Valid : BtnOk = 1 : Else : BtnOk = 0 : EndIf
If Type & #PB_Button_Cancel : BtnNo = 1 : Else : BtnNo = 0 : EndIf
If BtnOk = 0 And BtnNo = 1
MessageRequester("Erreur","Vous ne pouvez pas avoir un bouton "+Chr(34)+"Annuler"+Chr(34)+" si vous n'avez pas le bouton "+Chr(34)+"Ok"+Chr(34))
BtnOk = 1
ElseIf BtnOk = 0 And BtnNo = 0
MessageRequester("Erreur","Vous devez avoir au moins le bouton "+Chr(34)+"Valider"+Chr(34))
BtnOk = 1
EndIf
If TextAlignment& #PB_Text_Center And TextAlignment & #PB_Text_Right
TextAlignment = #Null
EndIf
If OpenWindow(#Win_Login,0,0,300,hText + 100,#PB_Window_TitleBar|#PB_Window_ScreenCentered,Titre)
If CreateGadgetList(WindowID(#Win_Login))
TextGadget(#Txt_Message, 10, 10, 280, hText, MsgClient, TextAlignment)
TextGadget(#Txt_Login,10,hText+20,135,15,"Nom d'utilisateur")
TextGadget(#Txt_Password,155,hText+20,135,15,"Mot de passe")
StringGadget(#Str_Login,10,35+hText,135,25,"")
StringGadget(#Str_Pass,155, 35+hText,135,25,"",#PB_String_Password)
If BtnOk And BtnNo
ButtonGadget(#Btn_Ok, (WindowWidth()/2)-105, 10 + hText+60,100,25,"Valider")
ButtonGadget(#Btn_No, (WindowWidth()/2)+5, 10 + hText+60,100,25,"Annuler")
Else
ButtonGadget(#Btn_Ok, (WindowWidth()/2)-50, 10 + hText+60,100,25,"Valider")
EndIf
EndIf
EnableWindow_(hWinForeGround, #False)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadgetID()
Case #Btn_Ok
Log\Login = GetGadgetText(#Str_Login)
Log\Pass = GetGadgetText(#Str_Pass)
EnableWindow_(hWinForeGround, #True)
ProcedureReturn @Log
Case #Btn_No
EnableWindow_(hWinForeGround, #True)
ProcedureReturn @Log
EndSelect
EndSelect
ForEver
CloseWindow(#Win_Login)
EndIf
EndProcedure
;- Test
*Info.LOGIN = LoginRequester_Ex("Login", "Entrez votre login"+Chr(10)+"s'il vous plaît"+Chr(10)+"Merci !!", #PB_Button_Valid|#PB_Button_Cancel, #PB_Text_Center)
Debug *Info\Login
Debug *Info\Pass

Chris
