Sign in to follow this  
Followers 0
au3scr

multiple windows

2 posts in this topic

Hi

If I have multiple windows and then close 1 then all windows will be closed.How i can code my script thatway when i close GUI created by button click action then Main window will still stay up?

I want that if i close Form2 then Form1 will stay up.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 116, 26, 193, 125)
$Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
        $Form2 = GUICreate("Form2", 116, 26, 193, 125)
        GUISetState(@SW_SHOW)   
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Use the advanced parameter of GUIGetMsg(). If you use 1 as a parameter (like GUiGetMsg(1)) then the function will return an array with the following information:

$array[0] = 0 or Event ID or Control ID

$array[1] = The window handle the event is from

$array[2] = The control handle the event is from (if applicable)

$array[3] = The current X position of the mouse cursor (relative to the GUI window)

$array[4] = The current Y position of the mouse cursor (relative to the GUI window)

So, you'd have to do something like this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 116, 26, 193, 125)
$Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
             if $nMsg[1]=$Form1 then exit;Exit if main window was closed
             GuiDelete($nMsg[1]);Delete the second form
        Case $Button1
        $Form2 = GUICreate("Form2", 116, 26, 193, 125)
        GUISetState(@SW_SHOW)   
    EndSwitch
WEnd

^NOT TESTED (But should work. Look into it at help file)

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