CB_ADDSTRING

CB_ADDSTRING

wParam = 0; /* not used, must be zero */

lParam = (LPARAM) (LPCSTR) lpsz; /* address of string to add */

An application sends a CB_ADDSTRING message to add a string to the list box of a combo box. If the combo box does not have the CBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted.

Parameters

lpsz

Value of lParam. Points to the null-terminated string to be added. If the combo box was created with an owner-drawn style but without the CBS_HASSTRINGS style, the value of the lpsz parameter is stored rather than the string it would otherwise point to.

Return Value

The return value is the zero-based index to the string in the list box of the combo box. The return value is CB_ERR if an error occurs; the return value is CB_ERRSPACE if insufficient space is available to store the new string.

Comments

If an owner-draw combo box was created with the CBS_SORT style but not the CBS_HASSTRINGS style, the WM_COMPAREITEM message is sent one or more times to the owner of the combo box so that the new item can be properly placed in the list.

To insert a string into a specific location within the list, use the CB_INSERTSTRING message.

The CB_ADDSTRING 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).

See Also

CB_DIR, CB_INSERTSTRING, WM_COMPAREITEM