PhilHibbs Posted May 21, 2010 Posted May 21, 2010 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.
Moderators SmOke_N Posted May 21, 2010 Moderators Posted May 21, 2010 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 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.
RogerH Posted May 28, 2010 Posted May 28, 2010 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) EndIfInteresting, 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
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