Sign in to follow this  
Followers 0
Cuervo

Controlling GUI Enable/Disable from an ini?

5 posts in this topic

#1 ·  Posted (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 by Cuervo

-Tim

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Cuervo

-Tim

Share this post


Link to post
Share on other sites

#5 ·  Posted (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. ;)

M23

P.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! :shocked:

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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