LB_SELECTSTRING

An application sends a LB_SELECTSTRING message to search for a string in the list box of a combo box, and if the string is found, to select the string in the list box, and copy it to the edit control.

The LB_SELECTSTRING message may be used as either a wide-character message (where text arguments must use Unicode) or an ANSI message (where text arguments must use characters from the Windows 3.x character set installed).

Parameters

wParam

Contains the zero-based index of the item before the first item to be searched. When the search reaches the bottom of the list box it continues from the top of the list box back to the item specified by wParam. If the wParam parameter is -1, the entire list box is searched from the beginning.

lParam

Points to the null-terminated string that contains the prefix to search for. The search is case-independent, so this string may contain any combination of uppercase and lowercase letters.

Return Value

The return value is the index of the selected item if the string was found. If the search was unsuccessful, the return value is LB_ERR and the current selection is not changed.

Comments

This message cannot be used with a list box that has the LBS_MULTIPLESEL style.

A string is selected only if its initial characters (from the starting point) match the characters in the string specified by the lParam parameter.

If the list box was created with an owner-draw style but without the LBS_HASSTRINGS style, this message returns the index of the item whose long value (supplied as the lParam parameter of the LB_ADDSTRING or LB_INSERTSTRING message) matches the value supplied as the lParam parameter of LB_FINDSTRING.

See Also

LB_ADDSTRING, LB_FINDSTRING, LB_INSERTSTRING