Cuervo Posted October 12, 2010 Share Posted October 12, 2010 (edited) Is it possible to change the state of a GUI box from an Ini file? This is the basics of what I was trying. $listCheck = IniRead($myIni, "authkeys", "box1", "notworking") $listmain = GUICtrlCreateCheckbox("My Check Box", 30, 150) If $listCheck = "working" Then GUICtrlSetState(-1, $GUI_ENABLE) Else GUICtrlSetState(-1, $GUI_DISABLE) EndIf The Ini file [authkeys] box1=working But oddly enough if the Ini file has just "box1=" without the word working it still enables the GUI check box. If the entire key is missing it will disable the check box. edit missing a comma in "authkeys", /edit Edited October 12, 2010 by Cuervo -Tim Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 12, 2010 Moderators Share Posted October 12, 2010 Cuervo,Your code works fine for me - the checkbox is enabled if the key is set correctly and disabled if the value or the entire key is missing. Have you checked the value of $listCheck before you run the If structure to see if it is what you are expecting? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Cuervo Posted October 12, 2010 Author Share Posted October 12, 2010 Cuervo, Your code works fine for me - the checkbox is enabled if the key is set correctly and disabled if the value or the entire key is missing. Have you checked the value of $listCheck before you run the If structure to see if it is what you are expecting? M23 I have not check what $listCheck returns. I'm not sure how to do that. My issue seems to be if the ini looks like this [authkeys] box1= The check box is still enabled when it should not be. Or for that matter: [authkeys] box1=happybox Leaves the check box enabled as well. -Tim Link to comment Share on other sites More sharing options...
Cuervo Posted October 12, 2010 Author Share Posted October 12, 2010 (edited) Ug! Sorry for wasting your time. "If you save the ini file after editing it" it might read the updated key value. It does in fact work. Edited October 12, 2010 by Cuervo -Tim Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 12, 2010 Moderators Share Posted October 12, 2010 (edited) Cuervo,Use something like this to check what you are getting from your ini:$listCheck = IniRead($myIni, "authkeys", "box1", "notworking") ConsoleWrite($listCheck & @CRLF)And the value will appear in SciTE's output pane.If i set my ini to box1=happybox then the Checkbox is disabled. There must be a problem elsewhere - perhaps if you posted all your code rather than just a snippet we might find it. M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Edit: See you found it - saving a new ini is always a good idea! Edited October 12, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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