|
Post by Walt Decker on Oct 12, 2021 13:28:54 GMT -5
Shortly after acquiring LB PRO I found a parser bug with STYLEBITS when using a variable to set the style of controls. I have found another that concerns the controls themselves.
Given: ' Ux = 5 Uy = 5 Wide = 100 High = 15
STATICTEXT #TST.LBL1, "NAME", Ux, Uy, Wide, High Uy = High + 5 Wide = 45 STATICTEXT #TST.LBL2, "LAST", Ux, Uy, Wide, High
OPEN "TEST" FOR WINDOW AS #TST WAIT '
The first static control does not display; the second displays as it should.
|
|
|
Post by Brandon Parker on Oct 12, 2021 14:30:19 GMT -5
Indeed, it looks like the "Uy" and "Wide" variables being set after the first StaticText are being parsed prior to setting the values for the first StaticText. I presume that is possibly caused in some part by how Liberty BASIC waits to create the controls until the window is opened (...obviously because you can't place a control on your window when it doesn't exist...). So, if you change the variables used for positioning prior to opening the window, the last will be used. In this case, both controls are being created, but the first one is being placed at the location of the second one. Due to Z-Order, the second StaticText is on top of the first one; if you make the first text portion longer, you can see this for sure. You could just forgo setting the variables a second time and place the actual math in the statements for the control instantiation as shown below. This will result in what you are after I believe and requires less code. Definitely an error though...  NoMainWin
Ux = 5 Uy = 5 Wide = 100 High = 15
StaticText #TST.LBL1, "NAME", Ux, Uy, Wide, High
StaticText #TST.LBL2, "LAST", Ux, (High + 5), (Wide - 55), High
Open "TEST" For Window As #TST #TST "TrapClose quit" Wait
Sub quit handle$ Close #handle$ End End Sub {:0) Brandon Parker
|
|
|
Post by Carl Gundel on Oct 12, 2021 18:59:58 GMT -5
Indeed, it looks like the "Uy" and "Wide" variables being set after the first StaticText are being parsed prior to setting the values for the first StaticText. I presume that is possibly caused in some part by how Liberty BASIC waits to create the controls until the window is opened (...obviously because you can't place a control on your window when it doesn't exist...). Yeah, that's pretty much right. I guess that's a bug, but more like a design quirk. Works better in LB5. 
|
|
|
Post by Walt Decker on Oct 13, 2021 8:59:35 GMT -5
Perhaps a better design would be to declare the controls AFTER specifying the form window. That could open a number of alternatives for the application designer.
|
|
|
Post by Carl Gundel on Oct 13, 2021 14:03:24 GMT -5
Perhaps a better design would be to declare the controls AFTER specifying the form window. That could open a number of alternatives for the application designer. I think the ability to add widgets to an open window is a good idea and I've been wanting to do that. It's on my list of things to do.
|
|