Jump to content
Sign in to follow this  
japino

Deselecting checkbox should deselect other checkbox

Recommended Posts

japino

I'm creating my first script with a GUI and I have created a dialog with a checkbox and an indented checkbox below the first checkbox. The indented checkbox should be deselected as soon as the user deselects the first checkbox. How should I go about this?

Share this post


Link to post
Share on other sites
MadBoy

; This ain't working code but should give you idea how to ;) 
Opt("GUIOnEventMode", 1)

$checkbox_1 = GUICtrlCreateCheckbox("Show log window", 12 + 323, 19)
$checkbox_2 = GUICtrlCreateCheckbox("Do something else", 12 + 323, 19 + 20)
GUICtrlSetOnEvent($checkbox_1, "_CheckboxStatusOne")
GUICtrlSetOnEvent($checkbox_2, "_CheckboxStatusTwo")

Func _CheckBoxStatusOne()
    GUICtrlSetState($checkbox_2, $GUI_UNCHECKED)
EndFunc   ;==>_CheckBoxStatusOne
Func _CheckboxStatusTwo()
    GUICtrlSetState($checkbox_1, $GUI_UNCHECKED)
EndFuncoÝ÷ ØGb´Z}ýµ¦âקíz¶¥Ú­æ­zÊ&zØb(®H Ê!z·²¢è(jëh×6; Working example
#Include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

 $Gui_Main = GuiCreate("Temp", 600, 600)

$checkbox_1 = GUICtrlCreateCheckbox("Show log window", 12 + 323, 19)
$checkbox_2 = GUICtrlCreateCheckbox("Do something else", 12 + 323, 19 + 20)
GUICtrlSetOnEvent($checkbox_1, "_CheckboxStatusOne")
GUICtrlSetOnEvent($checkbox_2, "_CheckboxStatusTwo")

GUISetState(@SW_SHOW, $Gui_Main)

While 1
    Sleep(1000)
Wend


Func _CheckBoxStatusOne()
    GUICtrlSetState($checkbox_2, $GUI_UNCHECKED)
EndFunc   ;==>_CheckBoxStatusOne
Func _CheckboxStatusTwo()
    GUICtrlSetState($checkbox_1, $GUI_UNCHECKED)
EndFunc

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
BrettF

Same thing but using GUIGetMsg...

; Working example
#Include <GUIConstants.au3>

$Gui_Main = GUICreate("Temp", 600, 600)

$checkbox_1 = GUICtrlCreateCheckbox("Show log window", 12 + 323, 19)
$checkbox_2 = GUICtrlCreateCheckbox("Do something else", 12 + 323, 19 + 20)

GUISetState(@SW_SHOW, $Gui_Main)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $checkbox_1
            GUICtrlSetState($checkbox_2, $GUI_UNCHECKED)
        Case $msg = $checkbox_2
            GUICtrlSetState($checkbox_1, $GUI_UNCHECKED)
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×