Jump to content

is there a way to disable/enable all controls within a group in one shot?


 Share

Recommended Posts

Hey guys,

So lets say I have a group with a couple of controls (some checkboxes, textboxes and things like that.)

If I want to disable all these controls I have to do a GUICtrlSetState on each one of them until I disable them all. And then to enable them I have to do it all over again on each one of them.

I want to clean up some of my code. Is there a way to just disable/enable all the controls within a group in one shot?

I tried to apply a GUICtrlSetState to the actual groupbox, but it doesn't do anything.

All I'm looking for is a simple way of doing this that I may have overlooked.

If it can only be done with heavy coding or some kind of custom function then it is not good for me as it will just add more code when I am trying to clean it up :)

Thanks :)

Edited by lemony
Link to comment
Share on other sites

lemony

Example:

#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Test GUI", 300, 200)

$DummyStart = GUICtrlCreateDummy()

GUICtrlCreateInput("", 50, 50, 200, 20)

GUICtrlCreateCheckbox("CheckBox", 50, 100, 65, 20)

GUICtrlCreateButton("Button", 150, 100, 75, 23)

$DummyEnd = GUICtrlCreateDummy()

$DisButton = GUICtrlCreateButton("Disable", 10, 160, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $DisButton
            If GUICtrlRead($DisButton) = "Disable" Then
                GUICtrlSetData($DisButton, "Enable")
                _Disable($GUI_DISABLE)
            Else
                GUICtrlSetData($DisButton, "Disable")
                _Disable($GUI_ENABLE)
            EndIf
    EndSwitch
WEnd

Func _Disable($sState)
    For $i = $DummyStart To $DummyEnd
        GUICtrlSetState($i, $sState)
    Next
EndFunc
:)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...