Thanks a lot for the hint about not having returned from an earlier event.
I have removed all code which is not necessary to demonstrate the problem... But the problem stays.
Here's my buggy code:
#include <GUIConstantsEx.au3>
#include <Debug.au3>
Opt("GUIOnEventMode", 1)
_DebugSetup ()
BuildSettingsGUI ()
BuildGUI ()
While True
Sleep (100)
WEnd
Func BuildGUI ()
Global $hGUI = GUICreate ("Main", 300, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "DoClose")
Global $ButtonMsg = GUICtrlCreateButton ("AAA", 10, 20)
GUICtrlSetOnEvent (-1 , "AAA")
Global $ButtonSetup = GUICtrlCreateButton ("Setup", 240, 20)
GUICtrlSetOnEvent (-1 , "ShowSettingsGUI")
GUISetState (@SW_SHOW, $hGUI)
EndFunc
Func DoClose()
_DebugOut ("DoClose")
Exit
EndFunc
Func BuildSettingsGUI ()
_DebugOut ("build SettingsGUI")
Global $hSettingsGUI = GUICreate ("Settings", 300, 165)
GUISetOnEvent($GUI_EVENT_CLOSE, "DoCloseSettings")
$BtnXXX = GUICtrlCreateButton ("xxx", 250, 10, 30, 30)
GUISetOnEvent (-1, "xxx")
EndFunc
Func ShowSettingsGUI ()
GUISetState (@SW_SHOW, $hSettingsGUI)
WinActivate ($hSettingsGUI)
_DebugOut ("done ShowSettingsGUI")
EndFunc
Func AAA()
_DebugOut ("A")
EndFunc
Func xxx()
_DebugOut ("X")
EndFunc
Func DoCloseSettings ()
_DebugOut ("close settings GUI")
GUISetState (@SW_HIDE, $hSettingsGUI)
WinActivate ($hGUI)
EndFunc
Thanks in advance for further hints!