Spinner class

A spinner is a control made of two buttons with up/down arrows to store, increment and decrement a value. A spinner normally work in conjunction with an edit box (the "buddy"). If the spinner control is created immediately after the edit box, they will operate together automatically. In this case the value stored in the spinner will always be shown in the edit box. The edit box can also be used for entering numbers manually. To create a spinner, use the function wb_create_control() passing Spinner as the parameter cclass.

The default range when a spinner is created is 0 to 100. To change the spinner range, use the wb_set_value() function.

In the windows handler, you should always process the edit box which is attached to the spinner, not the spinner itself. If you try to process the spinner control you will receive the messages twice. Similarly, you should always get or set the value of the edit box instead of trying to get/set the value of the spinner directly. If you do the latter, you may miss any changes made manually on the edit box.


// Create the edit box first

wb_create_control($mainwin, EditBox, "0", 340, 45, 35, 21, IDC_EDITBOX, WBC_VISIBLE | WBC_ENABLED | WBC_NUMBER);

// Then create the spinner. This is enough to make they work together

wb_create_control($mainwin, Spinner, "",  378, 45, 16, 21, IDC_SPINNER, WBC_VISIBLE | WBC_ENABLED);

// Set the spinner range

wb_set_value(wb_get_control($mainwin, IDC_SPINNER), null, -50, 50); 

NOTE: In the future it will be possible to create the edit box automatically together with the spinner control. In fact this will probably be the default behavior.

See also

Control classes