OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Responding To List Boxes

The member functions for modifying and querying list boxes let you set values or find out the status of the control at any given time.

To know what a user is doing to a list box at run time, however, you have to respond to notification messages from the control.

There are only a few things a user can do with a list box: scroll through the list, click an item, and double-click an item. When the user does one of these things, Windows sends a list box notification message to the list box's parent window. Normally, you define notification-response member functions in the parent window object to handle notifications for each of the parent's controls.

The following table summarizes the most common list box notifications:

List box notification messages

Event response table macroDescription
EV_LBN_SELCHANGEAn item has been selected with a single mouse click.
EV_LBN_DBLCLKAn item has been selected with a double mouse click.
EV_LBN_SELCANCELThe user has deselected an item.
EV_LBN_SETFOCUSThe user has given the list box the focus by clicking or double-clicking an item, or by using Tab. Precedes LBN_SELCHANGE notification.
EV_LBN_KILLFOCUSThe user has removed the focus from the list box by clicking another control or pressing Tab.

Here is a sample parent window object member function to handle an LBN_SELCHANGE notification:

void TLBoxWindow::EvListBoxSelChange()
{
int index = ListBox->GetSelIndex();
if (ListBox->GetStringLen(index) < 10) {
char string[10];
ListBox->GetSelString(string, sizeof(string));
MessageBox(string, "You selected:", MB_OK);
}
}
#define END_RESPONSE_TABLE
Definition eventhan.h:466
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
#define EV_LBN_SELCHANGE(id, method)
Definition windowev.h:492

See Also