Jump to content

GUI Windows


Monty
 Share

Recommended Posts

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

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
Link to comment
Share on other sites

#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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...