SonJoe Posted November 4, 2021 Share Posted November 4, 2021 Dear experts, I create 2 GUIs in separate functions and use the GUIOnEventMode, The firstly created GUI works fine, but the second one does not create events. Is there anything that distingushes between the first GUI an d a later created one, so that one creates the events and the other does not? Thanks in advance for your hints! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2021 Developers Share Posted November 4, 2021 When you looked at the wiki on Managing multiple gui's and you still can't figure out the issue, you really eed to post a reproducer script for us to understand why. It likely has to do with the fact you didn't return from an earlier called event. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SonJoe Posted November 5, 2021 Author Share Posted November 5, 2021 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: expandcollapse popup#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! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 5, 2021 Developers Share Posted November 5, 2021 (edited) You are using the wrong function for the "xxx". should be: GUICtrlSetOnEvent (-1 , "ShowSettingsGUI") ...by the way: a nice clean reproducer !! Edited November 5, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SonJoe Posted November 5, 2021 Author Share Posted November 5, 2021 Thanks, Jos, for your effort! Do you mean line 40? The Button "Setup" in the Main GUI already calls the Setup GUI. And this works: The Setup GUI opens. But then, within the Setup GUI, the Button "xxx" shall call the function "xxx". But this does not happen. When I click on the Button "xxx" within the Setup GUI, nothing happens. ... or have I misunderstood you idea? Link to comment Share on other sites More sharing options...
Solution MarvKLM Posted November 5, 2021 Solution Share Posted November 5, 2021 Hi. I think Jos meant to say, change this: $BtnXXX = GUICtrlCreateButton ("xxx", 250, 10, 30, 30) GUISetOnEvent (-1, "xxx") To: $BtnXXX = GUICtrlCreateButton ("xxx", 250, 10, 30, 30) GUICtrlSetOnEvent (-1, "xxx") It's not a Gui, it's a control. SonJoe 1 Link to comment Share on other sites More sharing options...
SonJoe Posted November 5, 2021 Author Share Posted November 5, 2021 Thanks a lot, MarvKLM. You're a genius! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 5, 2021 Developers Share Posted November 5, 2021 Yea right ... copied the wrong line in my answer ... JockoDundee 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now