lemony Posted May 24, 2008 Share Posted May 24, 2008 (edited) 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 May 24, 2008 by lemony Link to comment Share on other sites More sharing options...
Valuater Posted May 24, 2008 Share Posted May 24, 2008 Use Arrays to create the controls then you can loop through them with for/next and use GUICtrlSetState() in the middle of the loop 8) Link to comment Share on other sites More sharing options...
lemony Posted May 24, 2008 Author Share Posted May 24, 2008 (edited) Oh very cool! I would have never thought of that Thanks Valuater Edited May 24, 2008 by lemony Link to comment Share on other sites More sharing options...
rasim Posted May 24, 2008 Share Posted May 24, 2008 lemonyExample:expandcollapse popup#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 More sharing options...
Zedna Posted May 24, 2008 Share Posted May 24, 2008 lemonyExample: Very nice example using dummy controls rasim! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
lemony Posted May 24, 2008 Author Share Posted May 24, 2008 WOW that's an excellent code rasim, thanks! I never knew about GUICtrlCreateDummy or what it was meant for. But this is a nice way to use that! It works exactly for what I need 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