Moon Posted August 24, 2006 Posted August 24, 2006 I'm not quite sure I'm getting the hang of GUI controls and how their status affects variables. I've created a preferences menu with several checkboxes. Their initial state when opening the menu is set by the default settings I've read from an ini file. Thus the checkbox "shutdown computer when done" is not checked. OK, now when I check the checkbox and press cancel to leave the menu, the next time I open it the checkbox should be unchecked but unfortunately it isn't. What is wrong with this code? $checkbox_shutdown = GUICtrlCreateCheckbox("", 19, 193, 17, 17) IF $shutdown = 1 then GUICtrlSetState ($checkbox_shutdown, $GUI_CHECKED) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $checkbox_shutdown ; no $GUICtrlSetState since the GUI does it automatically? Case $msg = $button_cancel ExitLoop Case $msg = $button_ok $shutdown=GUICtrlRead($checkbox_shutdown) ExitLoop Case Else ;;;;;;; EndSelect WEnd GUIDelete()
GaryFrost Posted August 24, 2006 Posted August 24, 2006 To me cancel would mean don't change anything. However, I don't see you updating the Ini file in your code above either. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Moon Posted August 24, 2006 Author Posted August 24, 2006 Exactly, however, when I press Cancel using this code the checkbox is checked. Alright, I forgot to put in the ini code in my example but it doesn't change the outcome: Case $msg = $button_ok $shutdown=GUICtrlRead($checkbox_shutdown) code_to_write_variable_to_ini_file ExitLoop
GaryFrost Posted August 24, 2006 Posted August 24, 2006 Exactly, however, when I press Cancel using this code the checkbox is checked. Alright, I forgot to put in the ini code in my example but it doesn't change the outcome: Case $msg = $button_ok $shutdown=GUICtrlRead($checkbox_shutdown) code_to_write_variable_to_ini_file ExitLoop Depending on what your writing to the ini file and how your handling the data read in from the ini file $GUI_UNCHECKED = 4 $GUI_CHECKED = 1 IF $shutdown = 1 then GUICtrlSetState ($checkbox_shutdown, $GUI_CHECKED) i'm guessing $shutdown is the value read in from the ini also guessing the state is the value written to the ini just guessing. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Moon Posted August 24, 2006 Author Posted August 24, 2006 Your guess is ok. I'm not being too specific on this simply because my problem is the state of the checkbox. If I fire it up and it's uncheck, I check it and press cancel, the next time opening it should have it unchecked. That's not the case and I don't know why.
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