nitekram Posted December 2, 2016 Posted December 2, 2016 (edited) I created a GUI that dynamically creates labels and check boxes based upon a size of an array. Now I have decided to allow users to update the array via the same GUI that creates the above dynamically - how do I go about updating the GUI...without getting stuck in a never ending loop. Here is the part that creates the GUI: Local $GUI_Escalation = GUICreate('Escalation Manager', $iGUI_Width, $Height) For $x = 0 To UBound($aShowAllStatus) - 1 ConsoleWrite($aShowAllStatus[$x] & @CRLF) If $aShowAllStatus[$x] <> '' Then $CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $iCountAlerts * 35) ;$aTicketStartTimeInput[$x] = GUICTRLCreateInput('', 305, $iCountAlerts * 35, 75) Else $iCountAlerts -= 1 EndIf $iCountAlerts += 1 Next Local $ButtonClearAlerts = GUICtrlCreateButton('Remove All', $iGUI_Width - 130, $Height - 50, 100, 35) Local $ButtonRemoveAlerts = GUICtrlCreateButton('Remove Alert', $iGUI_Width - 130 * 2, $Height - 50, 100, 35) Local $ButtonChangeTimer = GUICtrlCreateButton('Change Timer', $iGUI_Width - 130 * 3, $Height - 50, 100, 35) Local $ButtonAddTimer = GUICtrlCreateButton('Add Timer', $iGUI_Width - 130 * 4, $Height - 50, 100, 35) GUISetState(@SW_SHOW) ; will display an empty dialog box And I am looking to find out how to either get out of the function and recall it with the updated information, or update the GUI? Edited December 2, 2016 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
InunoTaishou Posted December 2, 2016 Posted December 2, 2016 You could create a function that creates all of your variable controls and when you need to recreate the controls create another function that deletes the controls in the array using GUICtrlDelete expandcollapse popup; This is not runnable code but it should give you the general idea of what to do Local $GUI_Escalation = GUICreate('Escalation Manager', $iGUI_Width, $Height) Local $ButtonClearAlerts = GUICtrlCreateButton('Remove All', $iGUI_Width - 130, $Height - 50, 100, 35) Local $ButtonRemoveAlerts = GUICtrlCreateButton('Remove Alert', $iGUI_Width - 130 * 2, $Height - 50, 100, 35) Local $ButtonChangeTimer = GUICtrlCreateButton('Change Timer', $iGUI_Width - 130 * 3, $Height - 50, 100, 35) Local $ButtonAddTimer = GUICtrlCreateButton('Add Timer', $iGUI_Width - 130 * 4, $Height - 50, 100, 35) CreateCheckboxes() GUISetState(@SW_SHOW) ; will display an empty dialog box Switch (GUIGetMsg()) Case $ButtonClearAlerts DeleteControls($CheckBoxAlerts) Case $ButtonUpdate RecreateCheckboxes() EndSwitch Func RecreateCheckboxes() DeleteControls($CheckBoxAlerts) CreateCheckboxes() EndFunc Func DeleteControls(Const ByRef $aControls) For $i = 0 to UBound($aControls) - 1 GUICtrlDelete($aControls[$i]) Next EndFunc Func CreateCheckboxes() For $x = 0 To UBound($aShowAllStatus) - 1 ConsoleWrite($aShowAllStatus[$x] & @CRLF) If $aShowAllStatus[$x] <> '' Then $CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $iCountAlerts * 35) ;$aTicketStartTimeInput[$x] = GUICTRLCreateInput('', 305, $iCountAlerts * 35, 75) Else $iCountAlerts -= 1 EndIf $iCountAlerts += 1 Next EndFunc ;==>CreateCheckboxes
nitekram Posted December 2, 2016 Author Posted December 2, 2016 1 hour ago, InunoTaishou said: You could create a function that creates all of your variable controls and when you need to recreate the controls create another function that deletes the controls in the array using GUICtrlDelete expandcollapse popup; This is not runnable code but it should give you the general idea of what to do Local $GUI_Escalation = GUICreate('Escalation Manager', $iGUI_Width, $Height) Local $ButtonClearAlerts = GUICtrlCreateButton('Remove All', $iGUI_Width - 130, $Height - 50, 100, 35) Local $ButtonRemoveAlerts = GUICtrlCreateButton('Remove Alert', $iGUI_Width - 130 * 2, $Height - 50, 100, 35) Local $ButtonChangeTimer = GUICtrlCreateButton('Change Timer', $iGUI_Width - 130 * 3, $Height - 50, 100, 35) Local $ButtonAddTimer = GUICtrlCreateButton('Add Timer', $iGUI_Width - 130 * 4, $Height - 50, 100, 35) CreateCheckboxes() GUISetState(@SW_SHOW) ; will display an empty dialog box Switch (GUIGetMsg()) Case $ButtonClearAlerts DeleteControls($CheckBoxAlerts) Case $ButtonUpdate RecreateCheckboxes() EndSwitch Func RecreateCheckboxes() DeleteControls($CheckBoxAlerts) CreateCheckboxes() EndFunc Func DeleteControls(Const ByRef $aControls) For $i = 0 to UBound($aControls) - 1 GUICtrlDelete($aControls[$i]) Next EndFunc Func CreateCheckboxes() For $x = 0 To UBound($aShowAllStatus) - 1 ConsoleWrite($aShowAllStatus[$x] & @CRLF) If $aShowAllStatus[$x] <> '' Then $CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $iCountAlerts * 35) ;$aTicketStartTimeInput[$x] = GUICTRLCreateInput('', 305, $iCountAlerts * 35, 75) Else $iCountAlerts -= 1 EndIf $iCountAlerts += 1 Next EndFunc ;==>CreateCheckboxes I have tried to integrate your code within mine, but I am still getting some type of loop, as the first button changes color, back and forth. I may have to just redo my design, as I cannot find a way to update the GUI. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
InunoTaishou Posted December 2, 2016 Posted December 2, 2016 expandcollapse popup#include <GUIConstants.au3> Global $hMain = GUICreate("", 200, 400) Global $btnRecreate = GUICtrlCreateButton("Recreate", 10, 10, 180, 20) Global $aControls[0] CreateControls($aControls) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 Case $btnRecreate Local $iCount = InputBox("New Count", "How many controls to create", UBound($aControls)) If (Not @Error) Then RecreateControls($aControls, $iCount) EndSwitch WEnd Func RecreateControls(ByRef $aArray, Const $iNewSize) DeleteControls($aArray) ReDim $aArray[$iNewSize] CreateControls($aArray) EndFunc Func DeleteControls(ByRef $aArray) For $i = 0 to UBound($aArray) - 1 GUICtrlDelete($aArray[$i]) Next EndFunc Func CreateControls(ByRef $aArray) Local Static $iStartY = 40 For $i = 0 to UBound($aArray) - 1 $aArray[$i] = GUICtrlCreateLabel("Label " & $i, 10, $iStartY + ($i * 20), 180, 20) Next EndFunc
nitekram Posted December 2, 2016 Author Posted December 2, 2016 I thank you for your code and I see it works. I am having issues with my code, as I have to redo my code to match yours...I will attempt to work it out. Thanks again 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
nitekram Posted December 3, 2016 Author Posted December 3, 2016 That was not fun, but I finally was able to do it...to many functions to figure out lol. Thanks again for your input and help. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
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