Capone Posted September 14, 2008 Share Posted September 14, 2008 how would i make one check box uncheck another/others if checked? here's what i have $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 GuiGetMsg($Normal) If $Box1 = $GUI_CHECKED Then GUISetState($Box2, $GUI_UNCHECKED) EndIf If $Box2 = $GUI_CHECKED Then GUISetState($Box1, $GUIUNCHECKED) EndIf WEnd Link to comment Share on other sites More sharing options...
Triton Posted September 14, 2008 Share Posted September 14, 2008 If I understand correctly, you want to have if one box is checked then other predefined boxes unchecked if checked. $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Switch $msg Case $box1 If $Box2 = $GUI_CHECKED Then GUISetState($Box2, $GUI_UNCHECKED) Else GUISetState($Box2, $GUI_CHECKED) EndIf Case $Box2 If $Box1 = $GUI_CHECKED Then GUISetState($Box1, $GUI_UNCHECKED) Else GUISetState($Box1, $GUI_CHECKED) EndIf EndSwitch WEnd Triton Link to comment Share on other sites More sharing options...
Capone Posted September 15, 2008 Author Share Posted September 15, 2008 If I understand correctly, you want to have if one box is checked then other predefined boxes unchecked if checked. $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Switch $msg Case $box1 If $Box2 = $GUI_CHECKED Then GUISetState($Box2, $GUI_UNCHECKED) Else GUISetState($Box2, $GUI_CHECKED) EndIf Case $Box2 If $Box1 = $GUI_CHECKED Then GUISetState($Box1, $GUI_UNCHECKED) Else GUISetState($Box1, $GUI_CHECKED) EndIf EndSwitch WEnd i tried your idea and it didnt work properly but i see what your trying to do Link to comment Share on other sites More sharing options...
rasim Posted September 15, 2008 Share Posted September 15, 2008 (edited) CaponeExample:#include <GuiConstantsEx.au3> $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $box1 If GUICtrlRead($Box2) = $GUI_CHECKED Then GUICtrlSetState($Box2, $GUI_UNCHECKED) Else GUICtrlSetState($Box2, $GUI_CHECKED) EndIf Case $Box2 If GUICtrlRead($Box1) = $GUI_CHECKED Then GUICtrlSetState($Box1, $GUI_UNCHECKED) Else GUICtrlSetState($Box1, $GUI_CHECKED) EndIf EndSwitch WEnd Edited September 15, 2008 by rasim Link to comment Share on other sites More sharing options...
Capone Posted September 16, 2008 Author Share Posted September 16, 2008 Capone Example: #include <GuiConstantsEx.au3> $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $box1 If GUICtrlRead($Box2) = $GUI_CHECKED Then GUICtrlSetState($Box2, $GUI_UNCHECKED) Else GUICtrlSetState($Box2, $GUI_CHECKED) EndIf Case $Box2 If GUICtrlRead($Box1) = $GUI_CHECKED Then GUICtrlSetState($Box1, $GUI_UNCHECKED) Else GUICtrlSetState($Box1, $GUI_CHECKED) EndIf EndSwitch WEnd YOU ROCK! THANKS Link to comment Share on other sites More sharing options...
youknowwho4eva Posted September 17, 2008 Share Posted September 17, 2008 why not just use Radios? Giggity Link to comment Share on other sites More sharing options...
TheSovereign Posted May 30, 2009 Share Posted May 30, 2009 (edited) why not just use Radios?Perhaps the options are mutually exclusive, but neither is mandatory -- which is what I was looking to do. So, in my instance, this is what the code needs to look like: #include <GuiConstantsEx.au3> $GUI = GUICreate("Test", 364, 600) $Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) $Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Box1 If GUICtrlRead($Box2) = $GUI_CHECKED Then GUICtrlSetState($Box1, $GUI_CHECKED) GUICtrlSetState($Box2, $GUI_UNCHECKED) EndIf Case $Box2 If GUICtrlRead($Box1) = $GUI_CHECKED Then GUICtrlSetState($Box2, $GUI_CHECKED) GUICtrlSetState($Box1, $GUI_UNCHECKED) EndIf EndSwitch WEnd Many thanks to Capone and rasim for getting me on the right track with this. Edited May 30, 2009 by TheSovereign [font="Courier New"]__________________________________________________There is always another way, usually a better one.[/font] 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