Well I would do it this way (see code below).
It is a very light-weight template for doing multi windows apps.
Please bear in mind, that this is my favorite style with enums and one single main eventloop. But you can separate the events for each window or you can use the BindEvent functionality. (All up to you).
From my point of view, this could be a good start for your own MessageWindow, InputWindow, etc.
You can search the forum for much more. Look for "InputRequester" or "RequesterWindows" etc.
AFAIK the MessageBox_() function is a modal dialog box. The way mk-soft shows it only use no parent window, but still influences the event loop.
My template code (For all readers: Some windows API's are used for my convenience but not really needed):
Code: Select all
EnableExplicit
Enumeration EWindow 1
#WND_Main
#WND_ReqInput
#WND_ReqMessage
; tbc.
EndEnumeration
Enumeration EGadget 1
; WND_Main
#GDT_Main_btnInput
; tbc.
; WND_ReqInput
#GDT_ReqInput_imgIcon
#GDT_ReqInput_txtInfo
#GDT_ReqInput_strInput
#GDT_ReqInput_btnInput
; tbc.
; WND_ReqMessage
#GDT_ReqMessage_txtMessage
#GDT_ReqMessage_btnOK
; tbc.
EndEnumeration
#ProgramCaption$ = "Test "
#ProgramMainCaption$ = #ProgramCaption$ + "Ver. 0.0"
; ---
Procedure InputWindow(Info$, DefInput$="") ; more arguments like NParent, Size, ....
Protected hIcon
If IsWindow(#WND_ReqInput)
HideWindow(#WND_ReqInput, 0)
SetActiveGadget(#GDT_ReqInput_strInput)
SendMessage_(GadgetID(#GDT_ReqInput_strInput), #EM_SETSEL, $FFFF, $FFFF)
ElseIf OpenWindow(#WND_ReqInput, 0, 0, 320, 112, #ProgramCaption$, #PB_Window_SystemMenu|#PB_Window_WindowCentered, WindowID(#WND_Main))
hIcon = LoadIcon_(0, #IDI_WINLOGO) ; acc. to MSDN: default winlogo
ImageGadget(#GDT_ReqInput_imgIcon, 8, 8, 32, 32, hIcon)
TextGadget(#GDT_ReqInput_txtInfo, 48, 8, 320-56, 24, Info$)
StringGadget(#GDT_ReqInput_strInput, 48, 32, 320-56, 24, DefInput$)
SendMessage_(GadgetID(#GDT_ReqInput_strInput), #EM_SETSEL, $FFFF, $FFFF) ;
ButtonGadget(#GDT_ReqInput_btnInput, 128, 80, 64, 24, "OK")
SetActiveGadget(#GDT_ReqInput_strInput)
EndIf
EndProcedure
; ---
Procedure MessageWindow(Message$, Flags)
; tbc.
EndProcedure
; ---
Procedure CreateMainWindow()
If OpenWindow(#WND_Main, #PB_Ignore, #PB_Ignore, 400, 240, #ProgramMainCaption$, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#GDT_Main_btnInput, 160, 200, 64, 24, "Input")
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
; ---
Procedure Main()
Protected input$
If CreateMainWindow()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #WND_Main
Break ; bye
Case #WND_ReqInput
HideWindow(#WND_ReqInput, #True)
; ; or for all other windows
; Default
; HideWindow(EventWindow(), #True)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #GDT_Main_btnInput
InputWindow("Enter the new Value for somesthing....", "I don't know.")
Case #GDT_ReqInput_btnInput
input$ = GetGadgetText(#GDT_ReqInput_strInput) : Debug " Result = '" + input$ + "'"
; todo something ....
;CloseWindow(#WND_ReqInput) ; creates the window again next time
HideWindow(#WND_ReqInput, 1) ; this kept the position for the next time ???
; tbc.
EndSelect
EndSelect
ForEver
EndIf
ProcedureReturn 0
EndProcedure
End Main()