|
Post by johnking on Jul 8, 2020 1:55:17 GMT -5
is it possible to change the width of the prompt window (make it wider) ?
|
|
|
Post by honkytonk on Jul 8, 2020 2:37:02 GMT -5
In desperation, we can create a new window (virtual-promptbox-window), by respecting an inter-closing procedure. If the closure should cause an action, use state flags.
|
|
|
Post by Rod on Jul 8, 2020 3:21:38 GMT -5
The prompt is a standard Windows prompt, but it is just a window. Follow the link at the top of the forum to get to LBPE search out the stylebits discussion about dialog windowsThis is code straight out of the article by Janet. Nomainwin WindowWidth = 600 WindowHeight = 400
UpperLeftX = Int((DisplayWidth - WindowWidth)/2) UpperLeftY = Int((DisplayHeight - WindowHeight)/2)
Button #main.dlg, "Native Dialog", dlg, UL, 220, 200, 140, 30
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
|
|
|
Post by billknott on Mar 12, 2021 14:06:36 GMT -5
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.
'Use MultiPrompt Input Window to get data
title$ = "Main Title" subtitle1$ = "this is subtitle 1" subtitle2$ = "this is subtitle 2" Stext1$ = "text 1 .................." Stext2$ = "text 2 .................." Stext3$ = "text 3..................." Stext4$ = "text 4..................." NumTbx = 4
gosub [MultiPromptBox]
print box1$+" " ; val(box1$) print box2$+" " ; val(box2$) print box3$+" " ; val(box3$) print box4$+" " ; val(box4$) wait [MultiPromptBox] WindowWidth = 275 WindowHeight = ((30*NumTbx)+160) UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2) statictext #MultiPrompt.SubTitle1$, subtitle1$, 5,5,245,15 statictext #MultiPrompt.SubTitle2$, subtitle2$, 5,25,245,30 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
#MultiPrompt "trapclose [CloseMultiPrompt]" #MultiPrompt "font ms_sans_serif 8"
wait [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
|
|
|
Post by Rod on Mar 12, 2021 14:38:14 GMT -5
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.
open title$ for Dialog_modal as #MultiPrompt
|
|
|
Post by tsh73 on Mar 12, 2021 14:43:42 GMT -5
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
|
|
|
Post by billknott on Mar 12, 2021 15:14:03 GMT -5
OK, Thank you for that Rod and tsh73. I have edited the code to include your advices.
|
|
|
Post by johnking on Mar 12, 2021 15:23:53 GMT -5
Very nice !
|
|