#include <GUIConstantsEx.au3>
$ParentWin = GUICreate("Parent GUI", 250, 250)
$Button1 = GUICtrlCreateButton("Child window", 20,20,100)
$ParentWin_Pos = WinGetPos($ParentWin, "")
GUISetState(@SW_SHOW, $ParentWin)
$ChildWin = GUICreate("Child GUI", 250, 250, $ParentWin_Pos[0] + 100, $ParentWin_Pos[1] + 100, -1, -1, $ParentWin)
GUISetState(@SW_HIDE, $ChildWin)
While 1
$msg = GUIGetMsg(1)
Select
case $msg[0] = $Button1
GUISetState(@SW_SHOW, $ChildWin)
Case $msg[0] = $GUI_EVENT_CLOSE
If $msg[1] = $ChildWin Then
GUISetState(@SW_HIDE, $ChildWin)
ElseIf $msg[1] = $ParentWin Then
Exit
EndIf
EndSelect
WEnd