PDA

View Full Version : simple checkbox program example



hendryawan
26-02-2011, 14:33
Dear,
I want to know about checkbox in thin basic. I need simple program example using checkbox with check and uncheck result.

thank
regard

hendryawan

Petr Schreiber
26-02-2011, 14:46
Hi,

to add checkbox to your dialog, use something like (presuming your dialog handle is in hDlg and you have defined %idCheckBox control id):


Control Add Checkbox hDlg, %idCheckBox, "My checkbox", 5, 5, 100, 14


to set it checked:


Control Set Check hDlg, %idCheckBox, 1


to set it unchecked:


Control Set Check hDlg, %idCheckBox, 0


To retrieve, if it is checked (1) or unchecked (0), use the following:


DIM checkedState AS LONG

Control Get Check hDlg, %idCheckBox To checkedState

' now checkedState contains 1 or 0, according to current state


All of this functionality is documented in the help file. Adding controls is discussed under:
thinBasic Modules > UI (User Interface) > CONTROLs >

To open help file, just hit F1 in the IDE, or click Help/ThinBASIC Offline Help. The help file also supports seeking - you just switch to "Search" tab there, and enter for example "Checkbox" and it lists for you all related topics


Petr

hendryawan
26-02-2011, 22:06
I made the program but stil not work.
Please correct my program.

thank

hendryawan

Petr Schreiber
27-02-2011, 00:45
Hi hendryawan,

just change your callback to this:


CallBack Function writestate()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Control Get Check CBHNDL, %ID_Chk1 To checkedState
PrintL checkedState
End If
End If
End Function


-> so you check for the checkedState at the moment when you need it.


Petr

hendryawan
27-02-2011, 03:09
Thank youverymuch :p
regard

hendryawan