Ok i find out how to do it. Now i can make GUI from GUI. lol Now i have to learn to make buttons work
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Global $hGUI1, $hGUI2 = 9999, $hButton1, $hButton2, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements
gui1
()
Func gui1
()
$hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUISetState()
While 1
Sleep(10)
WEnd
EndFunc ;==>gui1
Func gui2
()
$hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUISetState()
EndFunc ;==>gui2
Func On
_Close
()
Switch @GUI_WINHANDLE ; See which GUI sent the CLOSE message
Case $hGUI1
Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<<
Case $hGUI2
GUIDelete($hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
GUICtrlSetState($hButton2, $GUI_ENABLE)
EndSwitch
EndFunc
Func On
_Button
()
Switch @GUI_CTRLID ; See which button sent the message
Case $hButton1
MessageBox
(1) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
Case $hButton2
GUICtrlSetState($hButton2, $GUI_DISABLE)
gui2
()
Case $hButton3
MessageBox
(2) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
EndSwitch
EndFunc
Func MessageBox
($iIndex)
MsgBox("", "MsgBox " & $iIndex, "Test from Gui " & $iIndex)
EndFunc
Func On
_Button
()
Switch @GUI_CTRLID ; See which button sent the message
Case $hButton1
MessageBox
(1) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
Case $hButton2
GUICtrlSetState($hButton2, $GUI_DISABLE)
gui2
()
Case $hButton3
MessageBox
(2) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
EndSwitch