Sign in to follow this  
Followers 0
PhilHibbs

Checkbox change event

3 posts in this topic

Can my GUI react to a checkbox being ticked and do something? I need to prompt the user for some information that is only relevant if a check box is ticked, and the best way I can think of is for it to pop up a prompt when they tick it but I can't find out how to detect this. I don't want to rewrite my whole GUI in OnEvent Mode.

Share this post


Link to post
Share on other sites



Interesting, there used to be examples of how to use a checkbox in the help file. The example there now is really stupid.

#include <GUIConstantsEx.au3>
#include <GUIButton.au3>

Example()

Func Example()
    Local $checkCN, $msg
    GUICreate("My GUI Checkbox")  ; will create a dialog box that when displayed is centered

    $checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20)

    GUISetState()       ; will display an  dialog box with 1 checkbox

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $checkCN
                If BitAND(GUICtrlRead($checkCN), $BN_CLICKED) = $BN_CLICKED Then
                    If _GUICtrlButton_GetCheck($checkCN) Then
                        ConsoleWrite("Checkbox checked... " & @CRLF)
                    Else
                        ConsoleWrite("Checkbox unchecked... " & @CRLF)
                    EndIf
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example

See if that fits your needs since you're not using OnEventMode


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

On my form, if I check one box, I have it disable another checkbox, and put a message in the input box I want the user to interact with:

I use the GUIGetMsg() method:

Case $cb_controller
            If GUICtrlRead($cb_controller) = $GUI_CHECKED Then
                GUICtrlSetData($in_system_name, @ComputerName)
                GUICtrlSetState($in_system_name, $GUI_DISABLE)
                GUICtrlSetState($cb_seccon, $GUI_ENABLE)
            Else
                GUICtrlSetData($in_system_name, "Fill in Controller Name here")
                GUICtrlSetState($in_system_name, $GUI_ENABLE)
                GUICtrlSetState($cb_seccon, $GUI_UNCHECKED)
                GUICtrlSetState($cb_seccon, $GUI_DISABLE)
            EndIf

Interesting, there used to be examples of how to use a checkbox in the help file. The example there now is really stupid.

See if that fits your needs since you're not using OnEventMode

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  
Followers 0