Contents Previous Next Subchapters

Using A Check Box In A Dialog Window
See Also radiobuttons

Description
Dialog "checkbox" controls are used to display a true or false option that the user can change.

addcontrol(
captiongeometry, "checkbox", name)
addcontrol(
captiongeometry, "checkbox", namecall back)
Adds a "checkbox" control, with the specified geometry , to the Dialog window specified by caption . The character row vector name specifies the label that is placed to the right of the check box. The command specified by call back is executed whenever the state of the check box is changed by the user. The return value is the control handle for the check box.

getcontrol(
handle)
Returns the current state of the "checkbox" control specified by handle, where handle is the value returned by addcontrol when the "checkbox" control was created. The return value is a logical scalar.

setcontrol(
handleflag)
Changes the current state of the "checkbox" control specified by handle to the value specified flag, where handle is value returned by addcontrol when the "checkbox" control was created and flag is a logical scalar. The return value of setcontrol is true, if the control can be set as requested, and false otherwise.

Example
The following program creates a dialog window with a push button labeled "Done" and a check box. The check box is initially set true. When the user changes the check box state, the new state is printed in the command window. When the button is pressed, the dialog is deleted.

clear
#
Caption  = "Test Dialog"
geometry = [100, 100, 200, 100]
callback = "delwin(Caption);"
adddialog(Caption, geometry, callback);
#
geometry = [20, 20, 150, 20]
text     = "Check Box"
StateLbl = "State ="
callback = "print StateLbl, getcontrol(Handle)"
Handle   = addcontrol(Caption, geometry, "checkbox", text, callback);
setcontrol(Handle, true);
#
geometry = [70, 50, 50, 20]
name     = "Done"
callback = "delwin(Caption);"
addcontrol(Caption, geometry, "pushbutton", name, callback);
#