Jump to content

Deselecting checkbox should deselect other checkbox


japino
 Share

Recommended Posts

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?

Link to comment
Share on other sites

; 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)

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...