Sign in to follow this  
Followers 0
dcat127

working with 2 windows.

2 posts in this topic

If I create 2 different windows, how can I come back to window 1 and add another button?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$window1 = GUICreate("window 1")
$window_1_button = GUICtrlCreateButton("Window 1 button", -1, -1)
GUISetState()
$window2 = GUICreate("window 2")
$window_2_button = GUICtrlCreateButton("Window 2 button", -1, -1)
GUISetState()

;make another button on window 1
$window_1_button2 = GUICtrlCreateButton("Window 2 button", 100, 100)

$msg = ""
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $window_1_button
            MsgBox(0, "", "Window 1 clicked")
        Case $msg = $window_2_button
            MsgBox(0, "", "Window 2 clicked")
    EndSelect
WEnd

Share this post


Link to post
Share on other sites



Found solution myself : use GUISwitch

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$window1 = GUICreate("window 1")
$window_1_button = GUICtrlCreateButton("Window 1 button", -1, -1)
GUISetState()
$window2 = GUICreate("window 2")
$window_2_button = GUICtrlCreateButton("Window 2 button", -1, -1)
GUISetState()

;make another button on window 1
GUISwitch($window1)
$window_1_button2 = GUICtrlCreateButton("Window 2 button", 100, 100)

$msg = ""
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $window_1_button
            MsgBox(0, "", "Window 1 clicked")
        Case $msg = $window_2_button
            MsgBox(0, "", "Window 2 clicked")
    EndSelect
WEnd

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