Horizon
Member in Training
Posts: 32
|
Post by Horizon on Jul 20, 2023 8:12:25 GMT
Hello,
I have a need to add a Minimise function to a Dialog window is this possible in Just BASIC? Would a alternative solution be to add a Minimise button or a button to Hide the window? The reason I ask this is that my program is a barcode scanner so the Dialog window type is beneficial for entering the scanned codes where you can capture the 'Enter' key...
button #win.default, "Enter" [enterScan], UL , 10, 10, 90, 25 ... which is really useful when scanning multiple barcodes.
I'd welcome any thoughts on this.
|
|
|
Post by tsh73 on Jul 20, 2023 8:54:38 GMT
Hello Horison 0) there is no way to manipulate windows system buttons in JB. If yu really need that, goto (4) 1) there is a "hide" /"show" command. But it does not work with Dialog winodws (or so it works for me) 2) but you can close dialog window instead of hiding it, and then re-open it (providing there is not much user-typed info in that window) 3) but how you will get an idea that winows should be shown back? one idea is to have small floating window with a button to open that window another - just end the program insead if hiding window, and re-run it again then window is needed?
(*4) option is to move on to Liberty BASIC (paid version of JB) with it, you can use default button in ordinary windows, or call Windows API to change window state (show/hide) (I cannot point a finger to examples but pretty sure I've seen that done)
EDIT here a way to change ordinary button in a window to Default button in LB (Liberty BASIC)
Stylebits #main.search, _BS_DEFPUSHBUTTON, 0,0,0
|
|
Horizon
Member in Training
Posts: 32
|
Post by Horizon on Jul 20, 2023 10:07:34 GMT
Hello tsh73 I appreciate the advice, it is a quite unique situation. I think I've found a way of doing this. Before: open "Barcode scanner v1.5" for dialog as #main After: open "Barcode scanner v1.6" for dialog_nf as #main adding _nf (window has no frame and cannot be resized by user) the minimise function is restored
|
|
|
Post by tsh73 on Jul 20, 2023 10:21:05 GMT
Glad you found a way.
Interesting, for me under Win 10 both dialog dilog_nf are non-resizable.
|
|
|
Post by Rod on Jul 20, 2023 10:54:05 GMT
If you are using a scanner it is useful to automate the input rather than have the operator press a key as well. But you can read both. Set the length to the length of your barcode. It will need some time out code or watch timer code to clear away unwanted input.
' set up a small window in the middle of the screen nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
' set up the controls that will be displayed in the window statictext #main.input, "Scan a barcode or press a key", 80, 20, 244, 20 statictext #main.result, "You entered", 80, 80, 244, 20 textbox #main.inbox, 80, 40, 300, 25 texteditor #main.rebox, 80, 100, 300, 125
' open the window and set where it goes if the user closes it open "Automated Barcode / User Input" for window as #main print #main, "trapclose [quit]"
'set a timer to read the textbox #main.inbox "!setfocus" timer 100, [read] wait
' when the button is clicked this code is actioned [read] timer 0 #main.inbox "!contents? code$" if len(code$)=13 then #main.rebox "barcode=";code$ : #main.inbox "" : #main.inbox "!setfocus" if len(code$)=1 then #main.rebox "User pressed :";code$ : #main.inbox "" : #main.inbox "!setfocus" timer 100, [read] wait
' when the user closes the window this code is actioned [quit] timer 0 close #main end
|
|
Horizon
Member in Training
Posts: 32
|
Post by Horizon on Jul 20, 2023 12:42:40 GMT
Hello Rod,
Thanks for the suggestion of the timeout input method (which never occurred to me), that approach and enables the flexibility of using a conventional window too.
|
|