Sign in to follow this  
Followers 0
Monty

GUI Windows

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Aceguy

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 :P

Edited by oMBra

Share this post


Link to post
Share on other sites

Very nice. Exactly what I was looking for. Thank you so much for your quick help guys.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0