Jump to content

OnEvent functions design


Recommended Posts

How are designed functions like GUICtrlSetOnEvent()? For example I want to create a function to update a control when system time is changed. Well this is quite simple even with AdlibRegister but would be nice to have a function to react just when time has been changed, not keep call a function 10 times/sec to see when the time is changed.

An example using AdlibRegister:

AdlibRegister("OnTimeChange",100)

$hMain = GUICreate("OnTimeChange",200,30)
$hCtrl = GUICtrlCreateLabel("",0,0,200,30,0x01)
GUICtrlSetFont($hCtrl,18,700,1,"Garamond")
GUISetState(@SW_SHOW,$hMain)

Do
     Sleep(10)
Until GUIGetMsg() = -3

Func OnTimeChange()
    Static $Last
    Local $New = @HOUR & ":" & @MIN
    If $New <> $Last Then
        GUICtrlSetData($hCtrl,$New)
        $Last = $New
    EndIf
EndFunc

I appreciate any idea. ;)

When the words fail... music speaks.

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...