Jump to content

Secondary GUI does not create events


Go to solution Solved by MarvKLM,

Recommended Posts

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 post
Share on other sites
  • Developers

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 post
Share on other sites

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!

Link to post
Share on other sites
  • Developers

You are using the wrong function for the "xxx". ;) should be: 

    GUICtrlSetOnEvent (-1 , "ShowSettingsGUI")

...by the  way: a nice clean reproducer !!

Edited 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 post
Share on other sites

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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...