Intercepts a Windows event on a control, a group of controls or a WINDEV or WINDEV Mobile window. A specific WLanguage procedure is automatically run when the event is triggered on the specified object. To end the management of the event, all you have to do is use EndEvent
Remark: Event does not operate on a non-WINDEV window.
// Capture the mouse click on an edit control
WM_LBUTTONDOWN is int = 513
Event(MouseClick, "EDT_EDIT1", WM_LBUTTONDOWN)
// MouseClick procedure
EDT_EDIT1 = "" // Reset the control to 0 when it is clicked
<Result> = Event(<WLanguage procedure> , <Object name> , <Windows message>)
- Identifier of event,
- 0 if an error occurs.
<WLanguage procedure>: Procedure name
Name of WLanguage procedure that will be run when intercepting the event. This procedure can be a global procedure of the project or a local procedure of the window that contains the code currently run. This function must comply with a specific standard (see the Remarks).
For a given object, a single procedure can intercept a given event.
<Object name>: Character string
Name of control, group of controls or WINDEV window on which the event will be managed. You also have the ability to use the following generic character strings:
|<Window name>.*||The event is managed for all the controls found in <Window name> (except for <Window name> itself).|
|.* (dot star)||The event is managed for all the controls found in the current window (except for the window itself).|
|*. (star dot)||The event is managed in all WINDEV windows of current application.|
|*.* (star dot star)||The event is managed in all WINDEV windows and in all controls of all opened WINDEV windows found in the current application.|
<Windows message>: Integer or character string
Number or name of Windows message to manage. See the list of Windows events. Remark: The Windows constants can be directly included in your WLanguage code via the EXTERN keyword.
If this parameter corresponds to a character string, this string is case-sensitive.
If this parameter corresponds to 0, all the Windows messages are intercepted.
Calling the same event several times on the same object
Event can be used to manage the same event several times for the same element (control, window, etc.).
In this case, the events are "stacked":
- the first event is managed until the next event is called.
- when an event is not managed anymore (EndEvent), the event found immediately before it (if it exists) is taken into account.
Procedure called by Event
The interception procedure called by Event
must have the following format:
FUNCTION ProcedureManageEvent(WindowsMessage, wParam, IParam)
WindowsMessage, wParam and lParam are three optional integers, used to send and to receive information about the message and the relevant objects.
Parameters used by the procedure
The interception procedure called by Event can use the following variables:
|Variables ||Meaning||5.5 variable kept for backward compatibility|
|MySelf..Name||Name of the object (control, group of controls or window)|
|Message||Number of the message (first parameter of the procedure)|
|wParam||First parameter of the message (second parameter of the procedure)|
|lParam||Second parameter of the message (third parameter of the procedure)|
|Handle("")||Handle of the object that received the message|
|Value returned by the procedure||Returns a value to Windows||_EVE.Return|
: If the process returns a value (an integer), the Windows event is stopped: this value is returned. If the process returns NO value, the execution continues.
Events used by WINDEV
WINDEV uses the events included between "WM_USER + 700" and "WM_USER + 1200". Therefore, other ranges of events must be used ("WM_USER + 1300" to "WM_USER + 1400" for example).