|
Post by spindizzy on Jan 11, 2020 18:25:28 GMT -5
I have created a programme and it works. But i am having difficulty with the "!setfocus" the programme has quite a simple front end with four input boxes , I require the focus to be on the first box ready for numerical input. Ive looked at other programmes and it seems very complicated to do something that would have been easy in old dialects of Basic. Ideally I want to type a number in the first box press enter and it progress to the next box. There are a lot of things that I find odd unexplained thingsabout this version of basic. for instance the way buttons and textboxes etc are created before the window they are going onto. which is the reverse of what you would would expect. I would be pleased if anyone can explain the "!setfocus" command Attachments:test interface.bas (1.11 KB)
|
|
|
Post by metro on Jan 11, 2020 18:31:13 GMT -5
Howdy spindizzy, take a look at the last post here libertybasiccom.proboards.com/thread/857/default-buttondoes that help you at all
or if you prefer just setting focus when the program first starts and you TAB to each field...which most windows programs expect
nomainwin
WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) BackgroundColor$="lightgrey"
textbox #WinOut.box1, 262, 76, 150, 30 textbox #WinOut.box2, 262, 116, 150, 30 textbox #WinOut.box3, 262, 156, 150, 30 textbox #WinOut.box4, 262, 195, 150, 30 statictext #WinOut.Label1, "TOP RADIUS", 138, 79,122, 25 statictext #WinOut.Label2, "BOTTOM RADIUS", 98, 120, 150, 25 statictext #WinOut.Label3, "DWELL ANGLE", 120, 160,140, 20 statictext #WinOut.Label4, "ANGLE INCREMENT", 75, 198, 180, 20 button #WinOut.button1, "EXECUTE", [CALCULATE], UL, 206, 280, 122, 35
open "CAM-GEN " for dialog_nf as #WinOut #WinOut.box1, "!setfocus" wait
[CALCULATE] print #WinOut.box1, "!contents? box1$" print #WinOut.box2, "!contents? box2$" print #WinOut.box3, "!contents? box3$" print #WinOut.box4, "!contents? box4$"
R1= val(box1$) R2= val(box2$) DA= val(box3$) A1= val(box4$)
end
|
|
|
Post by spindizzy on Jan 11, 2020 19:02:45 GMT -5
Howdy spindizzy, take a look at the last post here libertybasiccom.proboards.com/thread/857/default-buttondoes that help you at all
or if you prefer just setting focus when the program first starts and you TAB to each field...which most windows programs expect
nomainwin
WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) BackgroundColor$="lightgrey"
textbox #WinOut.box1, 262, 76, 150, 30 textbox #WinOut.box2, 262, 116, 150, 30 textbox #WinOut.box3, 262, 156, 150, 30 textbox #WinOut.box4, 262, 195, 150, 30 statictext #WinOut.Label1, "TOP RADIUS", 138, 79,122, 25 statictext #WinOut.Label2, "BOTTOM RADIUS", 98, 120, 150, 25 statictext #WinOut.Label3, "DWELL ANGLE", 120, 160,140, 20 statictext #WinOut.Label4, "ANGLE INCREMENT", 75, 198, 180, 20 button #WinOut.button1, "EXECUTE", [CALCULATE], UL, 206, 280, 122, 35
open "CAM-GEN " for dialog_nf as #WinOut #WinOut.box1, "!setfocus" wait
[CALCULATE] print #WinOut.box1, "!contents? box1$" print #WinOut.box2, "!contents? box2$" print #WinOut.box3, "!contents? box3$" print #WinOut.box4, "!contents? box4$"
R1= val(box1$) R2= val(box2$) DA= val(box3$) A1= val(box4$)
end
|
|
|
Post by spindizzy on Jan 11, 2020 19:05:54 GMT -5
Thanks Metro. I did put that command just like you have but it threw up an error wherever I put it. I did see the other post where they pressed enter and it moved onto the next box but it was hellishly complicated. It would have been nice to have done it that way. but we will live with it. Thanks
|
|
|
Post by metro on Jan 11, 2020 19:45:25 GMT -5
I'm not real crazy about this solution but it seems to work and its simple(r) real programmers may cringe
'global tb ' was used in a sub nomainwin
WindowWidth = 550
WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) BackgroundColor$="lightgrey"
textbox #WinOut.box1, 262, 76, 150, 30 textbox #WinOut.box2, 262, 116, 150, 30 textbox #WinOut.box3, 262, 156, 150, 30 textbox #WinOut.box4, 262, 195, 150, 30 statictext #WinOut.Label1, "TOP RADIUS", 138, 79,122, 25 statictext #WinOut.Label2, "BOTTOM RADIUS", 98, 120, 150, 25 statictext #WinOut.Label3, "DWELL ANGLE", 120, 160,140, 20 statictext #WinOut.Label4, "ANGLE INCREMENT", 75, 198, 180, 20 button #WinOut.button1, "EXECUTE", [CALCULATE], UL, 206, 280, 122, 35 button #WinOut.button2, "CLEAR ALL", [CLEARALL], UL, 206, 320, 122, 35 button #WinOut.default, "", [nexttb], ul, 0, 0, 1, 1 stylebits #WinOut.default, _BS_DEFPUSHBUTTON, 0, 0, 0 open "CAM-GEN " for dialog_nf as #WinOut #WinOut.box1, "!setfocus" tb=1 wait
[CALCULATE] print #WinOut.box1, "!contents? box1$" print #WinOut.box2, "!contents? box2$" print #WinOut.box3, "!contents? box3$" print #WinOut.box4, "!contents? box4$"
R1= val(box1$) R2= val(box2$) DA= val(box3$) A1= val(box4$) Notice "Your result is "; R1*R2 tb=1 #WinOut.box1, "!setfocus" WAIT [nexttb]
if tb= 1 then #WinOut.box2, "!setfocus" if tb=2 then #WinOut.box3, "!setfocus" if tb= 3 then #WinOut.box4, "!setfocus" if tb=4 then #WinOut.button1, "!setfocus" tb=tb+1 WAIT
[CLEARALL] print #WinOut.box1, "" print #WinOut.box2, "" print #WinOut.box3, "" print #WinOut.box4, "" #WinOut.box1, "!setfocus" WAIT
end
|
|
|
Post by spindizzy on Jan 12, 2020 7:46:37 GMT -5
Thanks , At least I can understand that . Other solutions I have seen I can not see how they work.
I still dont understand positioning of things in the programme for instance fonts; I have changed the fonts in the original prog but when you use set focus and wait it obviously isn't reading the fonts below but if i put them above then the set focus doesn't work.
It doesn't seem to have any logic about it. being an engineer i do things methodically This is why Im having difficulty with this Basic. I would have done things in sequence : create a window , specify fonts & colours, then print them to the window but this is all over the place. To me its like turning on the tap before you put the bucket underneath .lol
|
|
|
Post by Rod on Jan 12, 2020 8:15:50 GMT -5
Its just like setting out your tools and equipment before you start. In your original code the input cursor was set on the first textbox, tabbing moved the focus down the textboxes and finally to the button. So it was all lined up ready to go. Tabbing through controls is how Windows works and what most input folks would expect.
Taking control and forcing setfocus is ok too it just depends what your process is. Once the controls are established and the window is open, controls will respond to their command set, like hide show disable enable and setfocus. Some controls that display text need an ! ahead of the command. So they know its a command. Some don't. Perhaps that was where the difficulty was.
You won't find an easier BASIC that tames Windows GUI. So stick with it your time will not be wasted.
|
|
|
Post by spindizzy on Jan 12, 2020 8:20:38 GMT -5
Cheers Ive added your routine into my main prog and its working fine. except for fonts size.
|
|
|
Post by metro on Jan 12, 2020 8:22:29 GMT -5
You won't find an easier BASIC that tames Windows GUI. So stick with it your time will not be wasted. you also wont find a more helpful nicer group of people to answer your questions, they all have the patience of a saint
EDIT: font size works for me
open "CAM-GEN " for dialog_nf as #WinOut
#WinOut.box1, "!font courier_new 8 italic" #WinOut.box2 "!font arial 14 italic" #WinOut.box1, "!setfocus" tb=1 wait
|
|