CrewXp Posted August 21, 2007 Share Posted August 21, 2007 Hey, I'm creating GUI items, and after they're created, it puts them on a stack (i think its right...) But I want to call a function that deletes all of the ones on a stack when I'm done. What's the best way to do this? ;Test #include <Array.au3> Dim $cleanupstack $file = GUICtrlCreateInput ( "Password :: ", 10, 100, 220, 20) $btn = GUICtrlCreateButton ("Ok", 10, 150, 60, 20) _ArrayAdd( $cleanupStack,$file) _ArrayAdd( $cleanupStack,$btn) Func CleanUp() For $i=0 To _ArrayMaxIndex( $avArray, 1, 1) GUICtrlDelete(_ArrayPop($avArray)) Next EndFunc I'm not even sure if this works, as I'm not sure how to properly test it in my long code. Could someone help me out with this? Thanks. Link to comment Share on other sites More sharing options...
Sunaj Posted August 21, 2007 Share Posted August 21, 2007 Your code should work fine but I would use: For $i=1 To Ubound($avArray) -1 GUICtrlDelete($avArray[$i]) Next It is faster and no includes are needed that way Hey, I'm creating GUI items, and after they're created, it puts them on a stack (i think its right...) But I want to call a function that deletes all of the ones on a stack when I'm done. What's the best way to do this? ;Test #include <Array.au3> Dim $cleanupstack $file = GUICtrlCreateInput ( "Password :: ", 10, 100, 220, 20) $btn = GUICtrlCreateButton ("Ok", 10, 150, 60, 20) _ArrayAdd( $cleanupStack,$file) _ArrayAdd( $cleanupStack,$btn) Func CleanUp() For $i=0 To _ArrayMaxIndex( $avArray, 1, 1) GUICtrlDelete(_ArrayPop($avArray)) Next EndFunc I'm not even sure if this works, as I'm not sure how to properly test it in my long code. Could someone help me out with this? Thanks. [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
CrewXp Posted August 23, 2007 Author Share Posted August 23, 2007 doesn't work... I didn't think something that I wrote on the fly would actually work... any suggestions? #include <Array.au3> Dim $cleanupstack HotKeySet("{F6}","test") HotKeySet("{F7}","test2") Func test() $file = GUICtrlCreateInput ( "Password :: ", 10, 100, 220, 20) $btn = GUICtrlCreateButton ("Ok", 10, 150, 60, 20) _ArrayAdd( $cleanupstack,$file) _ArrayAdd( $cleanupstack,$btn) EndFunc Func test2() ;Msgbox(0,"",Ubound($cleanupstack)) For $i=0 To _ArrayMaxIndex( $cleanupstack, 1, 1) GUICtrlDelete(_ArrayPop($cleanupstack)) Next EndFunc Link to comment Share on other sites More sharing options...
CrewXp Posted August 23, 2007 Author Share Posted August 23, 2007 *bump* I'm stuck on this little problem for now, as it's holding my entire code back. So help is GREATLY appreciated!! Thanks Edit: Still trying. No luck. Link to comment Share on other sites More sharing options...
CrewXp Posted August 23, 2007 Author Share Posted August 23, 2007 I'm dumb... got it figured out. Link to comment Share on other sites More sharing options...
rover Posted August 23, 2007 Share Posted August 23, 2007 if you manually create array and items and don't use element zero for number of elements in array then you can use a For $element In $Array loop Local $avArray[2] HotKeySet("{F6}","test") HotKeySet("{F7}","test2") $gui = GUICreate("",240,200) GUISetState() While 1 Sleep(20) $msg = GUIGetMsg() If $msg = -3 Then Exit ; -3 is GUI constant $GUI_EVENT_CLOSE from #include <GUIConstants.au3> Wend Func test() $avArray[0] = GUICtrlCreateInput ( "Password :: ", 10, 100, 220, 20) $avArray[1] = GUICtrlCreateButton ("Ok", 10, 150, 60, 20) EndFunc Func test2() For $element In $avArray GUICtrlDelete($element) Next EndFunc I see fascists... 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