Open "Stylebits and Dialogs" for Window as #main Wait
Sub CloseMain handle$ Close #main End End Sub
Sub CloseDlg handle$ Close #handle$ End Sub
Sub dlg handle$ WindowWidth = 300 WindowHeight = 250
UpperLeftX = 20 'UpperLeftX 20 pixels to right of #main upper left corner UpperLeftY = 20 'UpperLeftY 20 pixels down from #main upper left corner
text$ = "UpperLeftX and UpperLeftY are, by default, based upon the client " text$ = text$;"coordinates of the calling window and not the screen coordinates." text$ = text$;Chr$(13);Chr$(13);"UpperLeftX = 20";Chr$(13);"UpperLeftY = 20" Statictext #dlg1, text$, 50, 50, 200, 200 Open "Dialog - No Stylebits" for Dialog_Modal as #dlg #dlg "Trapclose CloseDlg" End Sub
I was looking for a prompt window which could take more than one textbox and handle multiple data inputs. There didn't seem to be one. So here is my effort at producing one. You can make it wider with wider textboxes simply by changing the relevant width attributes.
'MultiPrompt Input Window
'Set up as many text boxes as required by offsetting the heights by 30. 'This example has 4 'If less are needed there is no need to re-write the code, 'just set the variable NumTBX to the lower number and the window will adjust.
if NumTbx > 0 then statictext #MultiPrompt.Txt1, Stext1$, 15,65,165,15 textbox #MultiPrompt.box1, 180,60,60,25 end if if NumTbx > 1 then statictext #MultiPrompt.Txt2, Stext2$, 15,95,165,15 textbox #MultiPrompt.box2, 180,90,60,25 end if if NumTbx > 2 then statictext #MultiPrompt.Txt3, Stext3$, 15,125,165,15 textbox #MultiPrompt.box3, 180,120,60,25 end if if NumTbx > 3 then statictext #MultiPrompt.Txt4, Stext4$, 15,155,165,15 textbox #MultiPrompt.box4, 180,150,60,25 end if button #MultiPrompt.default, "Accept", [Accept], UL 100, ((30*NumTbx)+70), 60, 30
Stylebits #MultiPrompt, _DS_CENTER, 0, 0, 0 open title$ for dialog_modal as #MultiPrompt
[Accept] if NumTbx > 0 then #MultiPrompt.box1, "!contents? box1$" end if if NumTbx > 1 then #MultiPrompt.box2, "!contents? box2$" end if if NumTbx > 2 then #MultiPrompt.box3, "!contents? box3$" end if if NumTbx > 3 then #MultiPrompt.box4, "!contents? box4$" end if notice "Done"
[CloseMultiPrompt] close #MultiPrompt return
Last Edit: Mar 12, 2021 15:11:50 GMT -5 by billknott
Cool. Rolling your own is one of Liberty BASIC's best skills. Consider _modal when popping up dialogs. This stops the user bypassing or closing them. _modal ensures they are responded to before the program moves on.
Prompt is modal dialog That is, it blocks other interactions until closed ("modal") Besides, Ok button works on Enter and it closes on ESC
If you change window type to dialog_modal, you will get all this (button to work as default (on Enter) should be named ".defaut") + some troubles positioning window (position normally based on parent window, but MAINWIN does not count)
It could be cured by stylebits (from link provided by Rod), so Stylebits #MultiPrompt, _DS_CENTER, 0, 0, 0 open title$ for dialog_modal as #MultiPrompt