Jump to content

[Solved] GuiOnEventMode not executing(?) functions


Recommended Posts

Tried to run this but nothing happens when I click the button. I'm a bit rusty on GuiOnEventMode but I fiddled around a bit and didn't managed it to work. I wrote a 300 lines program with GuiGetMsg() and i hand't any problems but I can't figure out this. I tried also to stick to the example on the help guide (which encloses all the gui creation code in a function called Test() and runs it and so I did) but without success

 

What I'm doing wrong?

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
GUICreate("Form1", 184, 97, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Button1 = GUICtrlCreateButton("HEY CLICK ME", 28, 23, 124, 49)
GUISetOnEvent(-1, "MyFunction")
GUISetState(@SW_SHOW)
Global $Iamrunning = False


While 1
    Sleep(10)
WEnd


Func MyFunction()
    MsgBox(0, "A", "A")
    If Not $Iamrunning Then
        MsgBox(0, "A", "B")
        $Iamrunning = True
        GUICtrlSetData($Button1, "I'm busy!")
        Sleep(10000)
        GUICtrlSetData($Button1, "HEY CLICK ME")
        $Iamrunning = False
    Else
        Return
    EndIf
EndFunc   ;==>MyFunction


Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc   ;==>SpecialEvents

 

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

OK that's embarassing. Should have looked it not twice but thousand times. Thanks

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...