PasswordBox

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

PasswordBox

Post by BackupUser »

Code updated for 5.20+ (same as InputRequester() with Flag: #PB_InputRequester_Password)

Restored from previous forum. Originally posted by Rings.

A simple Inputbox with hidden Textgadget and KeyEvent.
based on an earlier InputRequester from Franco:

Code: Select all

Procedure.s InputBox(Titel$)
  SizeX=220
  SizeY=100
  If OpenWindow(500,(GetSystemMetrics_(#SM_CXSCREEN)/2)-(SizeX/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-(SizeY/2),SizeX,SizeY,Titel$,0)
    
    
    hwnd=StringGadget(1,10,10,191,21,"")
    SendMessage_(hwnd,204,42,0)
    ButtonGadget(2,10,40,89,25,"Okay")
    ButtonGadget(3,110,40,89,25,"Abort")
    ;TextGadget(4,10,70,100,20,"TEST")
    
    SetForegroundWindow_(WindowID(500));SetForeGroundWindow_()
    ; ActivateGadget(1)
    Repeat
      EventID.l = WaitWindowEvent()
      Key.w= GetKeyState_( #VK_RETURN)
      If Key & %100000000000000
        ; MessageRequester("info","Return",0)
        dummy$=GetGadgetText(1)
        Quit=1
      EndIf
      ;SetGadgetText(4,Str(EventID)+":"+Str(Key.w))
      
      If EventID = #PB_Event_CloseWindow
        Quit=1
      EndIf
      
      If EventID = #PB_Event_Gadget
        
        Select EventGadget()
          Case 2
            dummy$=GetGadgetText(1)
            Quit=1
          Case 3
            Quit=1
        EndSelect
      EndIf
    Until Quit=1
  EndIf
  CloseWindow(500)
  ProcedureReturn dummy$
EndProcedure

Nop$=InputBox("Password")


Siggi