Sign in to follow this  
Followers 0
crashdemons

Trouble with GUISetOnEvent

4 posts in this topic

I am having a problem where several buttons on a GUI dont seem to want to play well with GUISetOnEvent

But external things like the close, restore and minimize buttons trigger correctly

There are no errors when ran, but the the "Enable" button ($button) never triggers the enableit() function when clicked.....

However, the close button does trigger CloseApp1()

:rolleyes:

This is kind of frustrating as I have used OnEvent mode in other applications that seem to work correctly.

:rambo: Please tell me if something is wrong here:

#function definition
Func CloseApp1()
    Exit
EndFunc
Func enableit()
    msgbox(0,"Enabled","Success")
EndFunc

#GUI creation
$gui=GUICreate("GUI",150,180)
$button=GUICtrlCreateButton("Enable",0,40,150,20)
GUISetState(@SW_SHOW,$gui)

#GUI triggers
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
GUISetOnEvent($GUI_EVENT_CLOSE,"CloseApp1")
GUISetOnEvent($button,"enableit")

#hold open
while 1
    sleep(500)
WEnd

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites



Have you overlooked:

Opt("GUIOnEventMode", 0)       ;0=disabled, 1=OnEvent mode enabled

----[ SandyD ]---

Share this post


Link to post
Share on other sites

Remember that there is OnEvent functions for Gui and OnEvent functions for Controls.

GUISetOnEvent($GUI_EVENT_CLOSE,"CloseApp1") <-- Gui

GUICtrlSetOnEvent($button,"enableit") <-- Ctrl

:rolleyes:

Share this post


Link to post
Share on other sites

Remember that there is OnEvent functions for Gui and OnEvent functions for Controls.

GUISetOnEvent($GUI_EVENT_CLOSE,"CloseApp1") <-- Gui

GUICtrlSetOnEvent($button,"enableit") <-- Ctrl

:rolleyes:

That's it ...I called it correctly in my other programs :rambo:

Thanks, lol what an embarassing mistake. :">


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


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
Sign in to follow this  
Followers 0