04-27-2018 02:22 PM
It looks like leaving a breadcrumb trail here for others may help, as I just had to solve this problem.
As previously mentioned, if you don't need to have the user actually type information into the text field, then just use a Ring Control (drop-down menu, but can't enter text).
If you must also have the ability for the user to enter text, then you need a ComboBox. To add this, in the panel uir file you go: right-click > Custom Controls > Toolslib Controls > Combo Box. Really, this only inserts a String control into your panel. You still have to instantiate the combo box using Combo_NewComboBox(panel, ctrl); then you have to destroy it using Combo_DiscardComboBox(panel, ctrl); when you are done. These functions come from including the combobox.h file.
When you use the Combo_NewComboBox function, under the hood combobox.c will actually create two additional controls in the CreateRing function: a Ring control and a Frame control. Even if you are moving/sizing the original String control using Splitters, when these new controls are NOT attached to your splitter when they come in. To move/size them correctly, you need access to the control handles (newRing and outline). To do this, I commented out the newRing and outline variables inside the CreateRing function in combobox.c. Then I called these variables out in a SharedGlobalVars.h file:
/* Ctrl IDs for new ComboBox controls */
int newRing;
int outline;
int gRingWidth;
(You will have put #include "SharedGlobalVars.h" in your combobox.h file, and initialize newRing and outline in the CreateRing function.)
Add in combobox.c:
gRingWidth = GetRingWidth(panel,control);
Add lines similar to these in your code:
//Attach newly-created elements of the combo box to be moved/sized by splitters. THIS HAS NO FRAME OF REFERENCE UNLESS YOU SET THE ATTR_TOP of the controls.
AddCtrlToSplitter(panel, hSplit1, VAL_TOP_ANCHOR, newRing, 1, 1);
AddCtrlToSplitter(panel, hSplit1, VAL_TOP_ANCHOR, outline, 1, 1);
SetCtrlAttribute(panel, newRing, ATTR_LEFT, Lbox - gRingWidth);
SetCtrlAttribute(panel, outline, ATTR_LEFT, Lbox - gRingWidth);
SetCtrlAttribute(panel, outline, ATTR_WIDTH, Wbox + gRingWidth);
//Set newRing and outline control positions to be the same as the top of the combo box ctrl, which is already attached to a splitter.
GetCtrlAttribute(panel, MyComboBox, ATTR_TOP, &Tbox); //This is actually the String control.
SetCtrlAttribute(panel, newRing, ATTR_TOP, Tbox);
SetCtrlAttribute(panel, outline, ATTR_TOP, Tbox);
This made all of the ComboBox elements move and scale together. I hope that helps.