|
Post by Walt Decker on Jan 18, 2021 15:13:53 GMT -5
Given:
GLOBAL LftCBxHndl, _ RgtCBxHndl
UpperLeftX = 300 UpperLeftY = 300 WindowWidth = 300 WindowHeight = 300
DIM A$(2) A$(0) = "PETER" A$(1) = "PIPER" A$(2) = "PICKED" COMBOBOX #WIN.LFT, A$(), ,05 , 10, 100, 200
A$(0) = "A" A$(1) = "PECK" A$(2) = "PEPPERS" COMBOBOX #WIN.RGT, A$(), ,115, 10 ,100, 200
OPEN "Combo Test" FOR WINDOW AS #WIN
LftCBxHndl = HWND(#WIN.LFT) RgtCBxHndl = HWND(#WIN.RGT) PRINT #WIN, "TRAPCLOSE DONE" WAIT END
'------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------
SUB DONE Hndl$
CLOSE #USER CLOSE #WIN END
END SUB
'------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------
Both comboboxes have the last values of A$()
Also there should be a way to populate a combobox by inserting or adding values without jumping through hoops to do so. CB_ADDSTRING AND CB_INSERTSTRING should be implimented.
|
|
|
Post by Chris Iverson on Jan 18, 2021 15:34:08 GMT -5
Is there some reason why the built in COMBOBOX RELOAD command is insufficient?
Change the A$() array, do #WIN.LEFT, "reload", and combobox is loaded with the values from A$().
As for why the two boxes wind up the same, I suspect it doesn't actually populate the combobox with the data until the window is actually opened, and the contents of the bound array have changed by then.
|
|
|
Post by Walt Decker on Jan 18, 2021 16:17:07 GMT -5
Yes. CB_ADDSTRING adds data to the bottom of the list. CB_INSERTSTRING places data at list index number. Much more simple. In an LB list/combobox, trying to use those does not work. It seems that LB stores the values in an array and uses that array to refresh the values. According to help: So "reload" does not accept an array. Changing the value of A$() would do nothing.
As for why the two boxes wind up the same, I suspect it doesn't actually populate the combobox with the data until the window is actually opened, and the contents of the bound array have changed by then. [/quote][/div]
That is my suspicion also. It should not be that way. The same problem is with STYLEBITS.
|
|
|
Post by Chris Iverson on Jan 18, 2021 17:57:08 GMT -5
Unless I'm misunderstanding you, you're wrong.
Change the values stored in the A$() array, and reload the combobox, and the values shown in the combobox will change.
Demo:
'Form created with the help of Freeform 3 v07-15-08 'Generated on Jan 18, 2021 at 16:49:34
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
dim cbData$(10) cbData$(1) = "One" cbData$(2) = "Two" cbData$(3) = "Three"
'-----Begin GUI objects code
ComboboxColor$ = "white" combobox #main.combobox1, cbData$(, [combobox1DoubleClick], 20, 17, 255, 120 button #main.button2,"Change",[button2Click], UL, 40, 92, 54, 25
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event wait
[combobox1DoubleClick] 'Perform action for the combobox named 'combobox1'
'Insert your own code here
wait
[button2Click] 'Perform action for the button named 'button2'
'Insert your own code here cbData$(4) = "Four" #main.combobox1, "reload"
wait
[quit.main] 'End the program close #main end
Run the code, a combobox with three items in it will appear. Press the button, and a fourth item will be added to the combobox.
I think you're expecting LB to be a lot more complicated, both internally and externally, than Carl ever intended it to be.
Before the OPEN statement, neither the Window nor do any of the controls on the window(sub-windows) exist. How exactly is LB supposed to populate information into a place that doesn't exist yet? It doesn't do anything complicated like trying to double-buffer the arrays the user binds the controls to. It just goes "okay, this array here. Got it. When I load the combobox, I'll pull whatever's currently in the array at that time."
It doesn't pre-create the windows to adjust on the fly. EVERYTHING gets created when you issue the OPEN statement.
All that said, I won't deny that having direct equivalents to ADD and INSERT would be very convenient, certainly managing the arrays can get tedious. But Carl went with the simplest implementation: use the programmer-provided array directly.
|
|
|
Post by Rod on Jan 19, 2021 5:47:16 GMT -5
The seed of the problem is using the same array for both combo boxes. That is not how Liberty asks for it to be done.
It is easy to insert, remove or reorder elements of a Combobox’s array and reload.
So we never really had a problem in the first place.
|
|
|
Post by Walt Decker on Jan 20, 2021 8:04:35 GMT -5
The seed of the problem is using the same array for both combo boxes. That is not how Liberty asks for it to be done. It is easy to insert, remove or reorder elements of a Combobox’s array and reload. So we never really had a problem in the first place. No comment.
|
|