Callback functions and window handlers

WinBinder implements a callback mechanism so the application script can easily process the events generated by controls or timers. While the main loop is active, the various controls and objects keep sending messages to the main application window whenever an event occurs. For example, if the user clicks a button or selects an item from a list view, a message is generated and transmitted to the function assigned as the current window handler.

The callback function

The callback function can have any valid PHP function name and has the following prototype:

        void fn_handler (int window, int id [, int ctrl [, int param1 [, int param2]]])

The name fn_handler is a placeholder for the actual function name. The parameter window is the window handle, id is the identifier of the object that generated the message, ctrl is the control (if it is the case) that generated the message, and param1 and param2 are custom values that depend on the class of the control that generated the message.

The callback function must be assigned to a window by a call to wb_set_handler().


In the callback function, param1 can receive the value IDDEFAULT to refer to the parent window itself instead of a control.


Look at the table in the windows messages and events page to see the events generated from all control classes.

Notification message flags

To enable additional messages in a particular window, you must include WBC_NOTIFY in the wb_create_window() function style parameter when creating the window and use param to indicate which additional notification messages you want to process. The flags are passed to the callback function via param1. The following notification flags are available:

Notification flag

Sent when


The control or the parent window was double-clicked.


The mouse cursor was moved over the main window.


A mouse button was pressed on the main window.


A mouse button was released on the main window.


A key was pressed when a given control has the focus.


A key was released when a given control has the focus.


A control has received the keyboard focus.


A request for screen redraw was posted on the message queue.


The parent window was resized.


A ListView column header was clicked or a TabControl tab is changed.

Mouse and keyboard notification messages can be further filtered using the following additional notification message flags:

See also

Windows messages and events
The main loop