atc Posted September 12, 2008 Posted September 12, 2008 In an application, I have a window created using GUICreate, eg. $CMWindow = GUICreate($CMW_Title,$CMW_Width,$CMW_Height) This window has a considerable number of input fields created using GUICtrlCreateEdit, eg. $CM_Funct_Edit = GUICtrlCreateEdit ("", $CM_Col2_Left, $CMWR_Top, $CM_Col2_Width, $CMW_Row_Height) $CM_ID_Edit = GUICtrlCreateEdit ("", $CM_Col2_Left, $CMWR_Top, $CM_Col2_Width, $CMW_Row_Height) .... Etc. In a few routines, I want to be able to loop through all of these controls, be able to (a) read the data, ( reset all or selected controls, and/or © identify each control when running through the loop. Is there a way I can loop through all controls in the window, identify each control and its type much as you can using Visual Basic Controls Collections? Obviously I could hard code the relevant controls in each routine. However, this can be tedious and is a problem for future program maintenance. Any help would be appreciated. Thanks
Triblade Posted September 12, 2008 Posted September 12, 2008 I use an array to store the control handles in that case. Check the program in my signature, it uses the same principle. Something(?) like: Local $control[11] For $i = 1 To 10 $control[$i] = GUICtrlCreateEdit("", 10, 10, 100, 20) GUICtrlSetData($control[$i], $i) ; Sets the controle number as data into the control Next My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
atc Posted September 12, 2008 Author Posted September 12, 2008 I use an array to store the control handles in that case. Check the program in my signature, it uses the same principle. Something(?) like: Local $control[11] For $i = 1 To 10 $control[$i] = GUICtrlCreateEdit("", 10, 10, 100, 20) GUICtrlSetData($control[$i], $i) ; Sets the controle number as data into the control NextThanks, That is one solution which I had considered and may well have to use. However, because I need to access specific conbtrols in some places and at other times, all controls - it was felt that I would need to assign two variables (one with a user friendly name & the other in an array element) as I would not trust the array element numbers to remain fixed with future modifications and enhancements.
PsaltyDS Posted September 12, 2008 Posted September 12, 2008 Thanks,That is one solution which I had considered and may well have to use. However, because I need to access specific conbtrols in some places and at other times, all controls - it was felt that I would need to assign two variables (one with a user friendly name & the other in an array element) as I would not trust the array element numbers to remain fixed with future modifications and enhancements.Then you could use a ScriptingDictionary object to store them.Or, you can do both, save them all to an array, and also assign specific variable for some that you need particular access to. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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