Listbox events and functions

Event function

event = func_id

The name of the function to be called when an event occurs for the listbox.

The function is called as follows:

func_id(event_code, listbox_id)

The events which cause the function to be called are:


The listbox has just been created.


The listbox has just been destroyed.


The listbox has gained focus.


The listbox has lost focus.


All selected lines in the listbox have been deselected. This is particularly useful with listboxes that can have multiple selections (edit mode EM_MULTIPLE). When a single line is selected, EV_UNSELALL is sent, informing the program that all previously selected lines have been unselected. EV_SELECT is then sent for the newly selected line.

The user has clicked down or released the right mouse button on the listbox.

If EV_RIGHT_MOUSE_UP is not trapped, releasing the right mouse button over a LIST_EDIT type listbox causes the Windows default menu to appear, with options to Undo, Cut, Copy, Paste, Delete and Select All.


The user has moved the mouse over the listbox during a dialog.


A keystroke is typed while the listbox has focus.


LIST_EDIT type only. The event is sent after each character typed into a list edit control.

One use of this event is a list that scrolls automatically as the user types, so that the list displays selectable values that match the text typed so far. This method is often used with Windows help systems, where the user is invited to type a keyword. To retrieve the value typed in to a list edit control, call the listbox_get_selected() function, either in the EV_LOSE_FOCUS event or in each EV_CHANGE event, as preferred.


The user has selected a row, by highlighting it via the cursor keys or other edit keys, or by means of a single click.


The user has executed a double mouse click on the listbox (LIST_BOX type only), or pressed the RETURN key within a listbox

The events EV_SINGLE_CLICK and EV_DOUBLE_CLICK do not indicate the selected line(s). The built-in functions listbox_get_selected() and is_selected() are used to retrieve the selected lines and their values.

A double click generates both the EV_SINGLE_CLICK and the EV_DOUBLE_CLICK events, in that order.


These events are not generated by default; they must always be specifically requested for the listbox by means of the event_enable = clause, e.g.

event_enable = EV_DEFAULT | EV_CHANGE

New events may be added in the future.

See Event functions.

Help function

help = func_id

The listbox help function. The function is called as follows:

func_id(EV_HELP, listbox_id)

See Help functions.

Event enable function

event_enable = flags

This clause is used to select the event codes which are to be enabled for the listbox.

Default: The standard set of events listed under the event = clause above.


event_enable = EV_DEFAULT | EV_CHANGE

See The event_enable clause.



Event functions