PHPWarner Posted December 28, 2009 Share Posted December 28, 2009 Hello, I need little help for checkboxes on GUI. Here is my sample form: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 206, 158, 192, 124) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 32, 16, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 32, 40, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 32, 64, 97, 17) $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 32, 88, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 32, 112, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd My question is, when I want to get value (checked or not) on $Checkbox1 with GUICtrlRead($Checkbox1) is it showing that label, Checkbox1 but I want to get checked or not value on one of the checkboxes. So how can I get value for checkboxes or radio buttons? Thank you so much. Link to comment Share on other sites More sharing options...
PHPWarner Posted December 28, 2009 Author Share Posted December 28, 2009 One addition to my question. Is it possible to check all or check none options? If yes, how to do it? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 28, 2009 Share Posted December 28, 2009 (edited) You can use line like this to see if a checkbox is checked. Use $GUI_UNCHECKED to see if its not. GUICtrlRead($Checkbox1) = $GUI_CHECKED Use this function to check or uncheck the box automatically GUICtrlSetState Edited December 28, 2009 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
PHPWarner Posted December 28, 2009 Author Share Posted December 28, 2009 (edited) It is getting error on GUICtrlRead($Checkbox1) = $GUI_CHECKED #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Form1", 231, 215, 462, 210) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 32, 16, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 32, 40, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 32, 64, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 32, 88, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 32, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 24, 136, 89, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 120, 136, 81, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlRead($Checkbox1) = $GUI_CHECKED GUICtrlSetState($Checkbox1, $GUI_CHECKED) EndSwitch WEnd Edited December 28, 2009 by PHPWarner Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 28, 2009 Share Posted December 28, 2009 Well the error message probably says something useful, but I can't read it from here.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
PHPWarner Posted December 28, 2009 Author Share Posted December 28, 2009 Okay, it seems to be checked value is 1 and unchecked value is 4. Please update me if I am wrong. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Form1", 231, 215, 462, 210) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox Test 1", 32, 16, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox Test 2", 32, 40, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox Test 3", 32, 64, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox4 = GUICtrlCreateCheckbox("Checkbox Test 4", 32, 88, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("Checkbox Test 5", 32, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 24, 136, 89, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 120, 136, 81, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "Checkbox Test 1", GUICtrlRead($Checkbox1)) MsgBox(0, "Checkbox Test 2", GUICtrlRead($Checkbox2)) MsgBox(0, "Checkbox Test 3", GUICtrlRead($Checkbox3)) GUICtrlSetState($Checkbox1, $GUI_CHECKED) MsgBox(0, "Checkbox Test 1", GUICtrlRead($Checkbox1)) EndSwitch WEnd Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 28, 2009 Share Posted December 28, 2009 Those values are correct. I use an If..Then statement to act on whether a checkbox is checked or not. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
PHPWarner Posted December 28, 2009 Author Share Posted December 28, 2009 Thank you so much. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now