Probiere es mal so:
Spoiler anzeigen
[autoit]
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$MainGui = GUICreate("Hallo", 500, 500, 0, 0)
$2GUI = GUICreate("2", 200, 200, 100, 100, $GUI_SS_DEFAULT_GUI, $WS_EX_MDICHILD, $MainGui)
GUISetState(@SW_SHOW, $2GUI)
GUISetState(@SW_SHOW, $MainGui)
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg[1]
Case $MainGui
If $nMsg[0] = $GUI_EVENT_CLOSE Then Exit
Case $2GUI
If $nMsg[0] = $GUI_EVENT_CLOSE Then Exit
EndSwitch
WEnd
Des weiteren empfehle ich dir den OnEventModus zu benutzen (GUISetOnEvent)