CrewXp Posted October 18, 2007 Share Posted October 18, 2007 (edited) expandcollapse popup#include <GUIConstants.au3> MainGui() Func MainGui() GLOBAL $maingui =GUICreate("CrewKit",240,180) GLOBAL $secondarygui =GUICreate("CrewKit Secondary",240,180,-1,-1,$WS_EX_TOOLWINDOW) GuiSetState(@SW_HIDE,$secondarygui) GuiSetState(@SW_ENABLE,$maingui) $button1=GUICtrlCreateButton ("Main Btn Ex", 0, 0, 100, 40,$BS_ICON) GUICtrlSetState(-1, $GUI_ENABLE) $launchbtn=GUICtrlCreateButton ("Launch 2nd GUI", 100, 0, 100, 40,$BS_ICON) GUISetState(@SW_SHOW, $maingui) GUICtrlSetState(-1, $GUI_ENABLE) While 1 $msg = GUIGetMsg() If $msg=$button1 Then MSgbox(0,"Example Function for the Main GUI (Button)","") If $msg=$launchbtn Then secondaryGUIFunc() EndIf WEnd EndFunc Func secondaryGUIFunc() GUISetState(@SW_DISABLE,$mainGUI) GUISetState(@SW_ENABLE,$secondaryGUI) GUISetState(@SW_SHOW,$secondaryGUI) GUISetState($secondaryGUI) ;Exits to mainGUI $exit=GUICtrlCreateButton ("Exit", 40, 130, 150, 20,$BS_ICON) ;Disabled, since there's nothing to go back to $back=GUICtrlCreateButton ("Back", 10, 130, 25, 25,$BS_ICON) ;This Creates new buttons for the secondaryGUI (a submenu) $subbtn=GUICtrlCreateButton ("Launch SubMenu", 0, 0, 100, 40,$BS_ICON) GUICtrlSetState (-1,1) ;Begin Loop While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $exit Then ; Exit/ Close GuiSetState(@SW_HIDE,$secondaryGUI) GuiSetState(@SW_DISABLE,$secondaryGUI) GuiSetState(@SW_ENABLE,$mainGUI) GuiSetState($mainGUI) GuiCtrlDelete($exit) GuiCtrlDelete($back) GuiCtrlDelete($subbtn) ExitLoop(1) EndIf If $msg=$subbtn Then GuiCtrlDelete($exit) GuiCtrlDelete($back) GuiCtrlDelete($subbtn) NEWsecondaryGUI() EndIf WEnd EndFunc Func NEWsecondaryGUI() $multpage=0 ;Exits to mainGUI, but doesn't work correctly. $exit=GUICtrlCreateButton ("Exit", 40, 130, 150, 20,$BS_ICON) ;Goes back to the original secondaryGUI buttons $back=GUICtrlCreateButton ("Back", 10, 130, 25, 25,$BS_ICON) ;Disabled, as this example program doesn't have many buttons $button2=GUICtrlCreateButton ("Sub-Menu Button Ex", 0, 0, 120, 40,$BS_ICON) GUICtrlSetState (-1,1) ; ;Begin Loop While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $exit Then ; Exit/ Close GuiSetState(@SW_DISABLE,$secondaryGUI) GuiSetState(@SW_HIDE,$secondaryGUI) GuiSetState(@SW_ENABLE,$mainGUI) GuiSetState($mainGUI) GuiCtrlDelete($exit) GuiCtrlDelete($back) GuiCtrlDelete($button2) ExitLoop(1) EndIf If $msg=$back AND $multpage=0 Then GuiCtrlDelete($exit) GuiCtrlDelete($back) GuiCtrlDelete($button2) secondaryGUIFunc(); EndIf If $msg=$button2 Then Msgbox(0,"","SubMenu ") EndIf WEnd EndFunc From the secondaryGUI, I can click Exit, and it will take me back. I can aslo click back, and it will take me back. But if I click Exit from the InstallPackage() Function, or click Exit from the cInstallPackages() after clicking the back button from InstallPackage(), it doesn't work. It closes the secondaryGUI, and shows the mainGUI. But I can't click on anything on it. It's like the buttons do nothing.. like the mainGUI while isn't working. I think it has something to do with the ExitLoop, since a new While is being called, but I'm not sure. In Summary: Exit being clicked from secondaryGUIFunc() works Exit being clicked from NEWsecondaryGUIFunc DOES NOT work. Exit being clicked from secondaryGUIFunc DOES NOT work after using the $back function in secondaryGUIFunc() Edited October 19, 2007 by CrewXp Link to comment Share on other sites More sharing options...
evilertoaster Posted October 18, 2007 Share Posted October 18, 2007 (edited) looks to be a problem similar to one a brought up a while back ( http://www.autoitscript.com/forum/index.php?showtopic=28292).You have to change how you have your script setup, a gui poll cannot run a new function untill the original returns...that's simply how it's implmented right now. Edited October 18, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
CrewXp Posted October 18, 2007 Author Share Posted October 18, 2007 (edited) Hey thanks, any idea on the best way to do that? EDIT: I edited my original post to include a working example script. Edited October 18, 2007 by CrewXp Link to comment Share on other sites More sharing options...
evilertoaster Posted October 18, 2007 Share Posted October 18, 2007 no matter what you do you have to make the first function call return. It's just a chagne in the way you may be thinking ;main GUI loop while if x call funcx if y call funcy wend funcx makeNewGUI() ;new gui loop while if z call funcz wend endfunc becomes ;main GUI loop while if x call funcx if y call funcy if z call funcz wend funcx MakeNewGUI() endfunc Link to comment Share on other sites More sharing options...
CrewXp Posted October 18, 2007 Author Share Posted October 18, 2007 so this is the only way?In a sense... I can put the if's and stuff in the secondarygui, right?Because it seems like the secondarygui works correctly. It's just that third while loop in the function that creates new buttons. Link to comment Share on other sites More sharing options...
evilertoaster Posted October 18, 2007 Share Posted October 18, 2007 hummm you're code is kinda hard for me to follow... My post partained particually to GUIOnEventMode but the same pricipial can hold true if you dont have your message polling set up correctly... From the looks of your code, you never escape the infinate loop of your 2nd GUI's return. If possible, redo your example script to be the most basic form of what you're trying to do (labling the buttoms could help also). I'm worried your polling logic is not setup to work how you think it is. Link to comment Share on other sites More sharing options...
CrewXp Posted October 19, 2007 Author Share Posted October 19, 2007 my original code is a LOT longer, that was a basic example, but I've edited it to be a 'little' more simpler. It's adjusted above. Edit: Been on it for about 5 hours now. Can't figure out just what I'm doing wrong.... I can re-write it like evilertoaster stated above, but I'm only half way through that (long code). Any ideas? Link to comment Share on other sites More sharing options...
CrewXp Posted October 19, 2007 Author Share Posted October 19, 2007 Fixed it!! It works the way I have it, but instead of deleting the buttons/controls of the secondaryGUI, I need to just hide the controls of it. Then re-enable them when done. And I created a GLOBAL variable of $time_to_exit, and the Exit on the NEWSecondaryGUI just sets that=1. If it's=1 in the secondaryGUI, it exits (since it works from there). Thanks. 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