Restored from previous forum. Originally posted by wayne1.
Code: Select all
;simple input box
;caution, not modal, but will stay above all other windows
;message=prompt
;caption=input box title
;defaultString=a suggested response
;
Procedure.s InputBox(message.s,caption.s,defaultString.s)
Protected xP=220, yP=200, xW=365, yH=140
Protected inpBoxHnd, answer.s = "", OKorCan.b, EventID
#TOP_MOST=-1
If OpenWindow(0, xP, yP, xW, yH, caption, #PB_Window_SystemMenu )
ButtonGadget(0, 290, 10, 60, 22, "OK")
ButtonGadget(1, 290, 35, 60, 22, "Cancel")
TextGadget(2, 10, 10, 275, 25, message)
StringGadget(3, 10, 80, 340, 20, defaultString)
SetActiveGadget(3)
inpBoxHnd= FindWindow_(0, caption)
SetWindowPos_(inpBoxHnd,#TOP_MOST,xP,yP,xW,yH,0);set InputBox to TOP_MOST (above all other windows)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
answer=""
Goto exit
EndIf
If EventID = #PB_Event_Gadget
Select EventGadget()
Case 0
answer=GetGadgetText(3)
EventID = #PB_Event_CloseWindow
OKorCan=1
Case 1
answer=""
EventID = #PB_Event_CloseWindow
OKorCan=1
EndSelect
If OKorCan
Goto exit
EndIf
EndIf
ForEver
exit:
EndIf
CloseWindow(0)
ProcedureReturn answer
EndProcedure
Repeat
a$=InputBox("Enter Your Name","Input Box","")
If a$ <> ""
MessageRequester("Your Name",a$,0)
Else
MessageRequester("","You did not enter anything or you pressed cancel or exit.",0)
EndIf
Until a$ <> ""
End