Jump to content

Recommended Posts

Posted (edited)

This small UDF allows to set events for the controls without using GUIOnEventMode.

Also the events function can accept parameters (actually one parameter, which can be an array).

 

Remark: $WM_COMMAND registered by this UDF, so if you or other UDF uses this message, please call __GCSOEE_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) from that message function to allow this UDF to work properly.

Not relevant anymore.

 

Example:

#include <GUIConstantsEx.au3>
#include 'GUICtrlOnEvent.au3'

$hGUI = GUICreate('GUICtrlOnEvent Example', 300, 200)

$iButton = GUICtrlCreateButton('Button', 20, 40, 60, 20)
_GUICtrlOnEvent_SetEvent($iButton, _Events, 'Button Param')

$iLabel = GUICtrlCreateLabel('Label', 20, 80, 60, 20)
_GUICtrlOnEvent_SetEvent($iLabel, _Events, 'Label Param')

$iInput = GUICtrlCreateInput('Input', 20, 120, 60, 20)
_GUICtrlOnEvent_SetEvent($iInput, _Events, 'Input Param')

Dim $aEventKeys[] = [$VK_LBUTTON, $VK_RETURN]
_GUICtrlOnEvent_SetEventKeys($aEventKeys)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _Events($hWnd, $iCtrlID, $vParam)
    Switch $iCtrlID
        Case $iButton
            MsgBox(64, $vParam, 'Clicked Button ID: ' & $iCtrlID, 0, $hWnd)
        Case $iLabel
            MsgBox(64, $vParam, 'Clicked Label ID: ' & $iCtrlID, 0, $hWnd)
        Case $iInput
            MsgBox(64, $vParam, 'Clicked Input ID: ' & $iCtrlID, 0, $hWnd)
    EndSwitch
EndFunc

 

GUICtrlSetOnEventEx.zipFetching info...

GUICtrlOnEvent_0.2.zipFetching info...

Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

The question is, what is considered an event, if it's only a click, then the solution is simple.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Update...

  Quote

v0.2

* UDF renamed to GUICtrlOnEvent.
* _GUICtrlSetOnEventEx renamed to _GUICtrlOnEvent_SetEvent.
+ Added _GUICtrlOnEvent_SetEventKeys function to set keys trigger.
* Removed $WM_COMMAND message registration.
* Fixed issue with constantly executed event.

Expand  

 

Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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