Post by jarychk on Jul 10, 2024 5:18:25 GMT
Subject of topic may need to be changed or adjusted.
Programmers learning to use Just BASIC, when creating a program with a top window (first one that appears upon opening the program) which opens one or more lower level windows, should choose their window handles, control-extensions, labels of controls, and flag variables, very carefully. This will help when reading through the code while building the program.
Imagine a user closes an upper level window without closing a lower level window which that upper level window can open.
I must share this demonstration example:
Programmers learning to use Just BASIC, when creating a program with a top window (first one that appears upon opening the program) which opens one or more lower level windows, should choose their window handles, control-extensions, labels of controls, and flag variables, very carefully. This will help when reading through the code while building the program.
Imagine a user closes an upper level window without closing a lower level window which that upper level window can open.
I must share this demonstration example:
'handlelabelflag july 9 2024
'relearn better to work with levels fo window opening and closing
'and selection to better identify levels of label of controls
'and of window handles
'FLAG VARIABLES FOR WINDOW CONTROL
flag2a=0
flag2b=0
nomainwin
WindowWidth = 360
WindowHeight = 330
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #top.buttonLev2a, "take me down one", [buttonLev2a], UL, 46, 71, 216, 30
button #top.buttonLev2b, "Or take me down one, too", [buttonLev2b], UL, 46, 151, 216, 35
open "level top" for window as #top
print #top, "trapclose [quit.top]"
print #top, "font ms_sans_serif 10"
wait
[quit.top]
'be ssure to close any "level middle" windows before trying
'to close top window.
if flag2a=1 then close #middle
if flag2b=1 then close #middle2b
'and not necessary to reset those flag variables here
Close #top
END
[buttonLev2a] 'Perform action for the button named 'buttonLev2a'
'Insert your own code here
if flag2a=1 then wait
nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #middle.middle2a, "level middle, 2a", 198, 151, 144, 20
open "middle level" for window as #middle
print #middle, "trapclose [quit.middle]"
print #middle, "font ms_sans_serif 10"
flag2a=1
wait
[quit.middle]
Close #middle
flag2a=0
'END
wait
[buttonLev2b] 'Perform action for the button named 'buttonLev2b'
'Insert your own code here
if flag2b=1 then wait
nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #middle2b.mid2b, "middle level, 2b", 190, 151, 144, 20
open "middle level, but alternative" for window as #middle2b
print #middle2b, "trapclose [quit.middle2b]"
print #middle2b, "font ms_sans_serif 10"
flag2b=1
wait
[quit.middle2b]
Close #middle2b
flag2b=0
'END
wait