Monty Posted October 21, 2008 Share Posted October 21, 2008 Ok, here is what I am having issues with, so if someone can please help me out. Below code (just an example) open GUI called "Window 1" with the button "Test". When button Test is pressed, it calls a function TestWindow() and this opens another window called "Test Window". When I close "Test Window" it also closes "Window 1". How can I modify this code so when "Test Window" is closed, "Window 1" remains open. #include <GUIConstants.au3> GUICreate("Window 1", 400, 300) $Button = GUICtrlCreateButton("Test", 20, 20, 90, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button TestWindow() EndSelect Wend Func TestWindow() GUICreate("Test Window", 200, 100) GUISetState() EndFunc Link to comment Share on other sites More sharing options...
Aceguy Posted October 21, 2008 Share Posted October 21, 2008 (edited) it because your GUI_EVEN_CLOSE in the main loop is detecting both close buttons... so you it doesnt matter which one you click. there problably is a better way to do this,... but this is my effort #include <GUIConstants.au3> $wind1=GUICreate("Window 1", 400, 300) $Button = GUICtrlCreateButton("Test", 20, 20, 90, 25) global $wind2 GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE if WinExists("Test Window")=1 Then GUIDelete($wind2) Else Exit EndIf Case $msg = $Button TestWindow() EndSelect Wend Func TestWindow() $wind2=GUICreate("Test Window", 200, 100) GUISetState() EndFunc Edited October 21, 2008 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
oMBRa Posted October 21, 2008 Share Posted October 21, 2008 (edited) #include <GUIConstants.au3> $Mywindow = GUICreate("Window 1", 400, 300) $Button = GUICtrlCreateButton("Test", 20, 20, 90, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Case $msg = $Button TestWindow() Case Not WinExists($Mywindow) Exit EndSelect WEnd Func TestWindow() GUICreate("Test Window", 200, 100) GUISetState() EndFunc;==>TestWindow @Monty next time wrap your code in code tags it makes it easier to read Edited October 21, 2008 by oMBra Link to comment Share on other sites More sharing options...
Monty Posted October 21, 2008 Author Share Posted October 21, 2008 Very nice. Exactly what I was looking for. Thank you so much for your quick help guys. 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