I found this code of AKJ

But the field text loose the focus, if i clic out of the windows
The windows is really modal yes, but the keyboard can't write in the StringGadget
I'm forced to select the windows, and give it focus to write new time in the stringGadget

I search an InputBox full modal.
When she is enabled, impossible to do anything, even in another application, and the stringGadget always be active, is it possible ????
http://www.purebasic.fr/english/viewtop ... 71#p166571
Code: Select all
Procedure.s InputBox(txtw, txth, title$, prompt$, def$="", flags=0)
; A version of InputRequester() by BackupUser
; Modified by AKJ 18-Oct-06
; Downloaded: www.purebasic.fr/english/viewtopic.php?t=2412
; textw and txth are the outer dimensions of the prompt text gadget
; Available flags are:
; #PB_String_{BorderLess LowerCase Numeric Password ReadOnly Uppercase}
; Features:
; (1) Modal (locks the calling window until done)
; (2) Prompt area is larger
; (3) Prompt area supports multi-line text with Chr(13)
; (4) Cancel button in addition to OK button
; (5) Returns the default string (def$) if the Cancel button is pressed
; (6) Returns "" if an error occurs
; (7) Standard Windows look-And-feel
; (8) Plays the "question" prompt sound
; (9) Works with or without a calling window
;(10) Emulates the Visual Basic InputBox() command
;(11) Supports all #PB_String_xxx flags
Protected winBox, txtPrompt, strInput, butOK, butCancel ; Gadgets
Protected box, ev, id, ret, esc, a, thread1, thread2, text$=""
If txtw<128
xtw=128
EndIf ; To show buttons correctly
If txth<20
txth = 20
EndIf ; Height of a normal text line
winBox=OpenWindow(#PB_Any,0,0,txtw+13,txth+20+23+8*4,title$,#PB_Window_ScreenCentered)
box=WindowID(winBox)
If winBox
txtPrompt=TextGadget(#PB_Any,6,8,txtw,txth,prompt$)
If flags&#PB_String_Password=0
flags|#ES_MULTILINE
EndIf
strInput=StringGadget(#PB_Any,6,txth+8*2,txtw,20,def$,flags|#ES_AUTOVSCROLL)
butOK=ButtonGadget(#PB_Any,6,txth+20+8*3,60,23,"OK") ; Set x=txtw-122 for button to be on the right
butCancel=ButtonGadget(#PB_Any,txtw-54,txth+20+8*3,60,23,"Cancel")
SendMessage_(GadgetID(strInput),#EM_SETSEL,0,Len(def$))
GetAsyncKeyState_(#VK_RETURN)
GetAsyncKeyState_(#VK_ESCAPE)
StickyWindow(winBox,#True)
SetForegroundWindow_(box)
SetActiveGadget(strInput)
MessageBeep_(#MB_ICONQUESTION)
Repeat
ev=WaitWindowEvent(1)
id=EventGadget()
ret=GetAsyncKeyState_(#VK_RETURN)
esc=GetAsyncKeyState_(#VK_ESCAPE)
a=GetForegroundWindow_()
If a<>box
thread1=GetWindowThreadProcessId_(@a,0)
thread2=GetWindowThreadProcessId_(@box,0)
If thread1<>thread2
AttachThreadInput_(thread1,thread2,#True)
EndIf
SetForegroundWindow_(box)
Sleep_(1)
If thread1<>thread2
AttachThreadInput_(thread1,thread2,#False)
EndIf
SetActiveGadget(strInput); !!! : MessageBeep_(#MB_ICONQUESTION)
EndIf
Until (ev=#PB_Event_Gadget And (id=butOK Or id=butCancel)) Or ret<>0 Or esc<>0 Or ev=#PB_Event_CloseWindow
If id=butOK Or ret<>0
text$=GetGadgetText(strInput)
Else
text$=def$
EndIf
CloseWindow(winBox)
EndIf
ProcedureReturn text$
EndProcedure
; Example using BackupUser's dimensions for the prompt text gadget
Debug InputBox(487, 70, "Test", "Enter something:", "default", #PB_String_UpperCase)