CB_ADDSTRING

This message is sent by an application 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.

At a Glance

Header file: Winuser.h
Windows CE versions: 1.0 and later

Syntax

CB_ADDSTRING wParam = 0, lParam = (LPARAM)(LPCSTR) lpsz

Parameters

lpsz

Long pointer to the null-terminated string to be added. If you create the combo box with an owner-drawn style but without the CBS_HASSTRINGS style, the value of the lpsz parameter is stored as item data rather than the string it would otherwise point to. The item data can be retrieved or modified by sending the CB_GETITEMDATA or CB_SETITEMDATA message.

Return Values

The zero-based index to the string in the list box of the combo box indicates success. CB_ERR indicates that an error has occurred. CB_ERRSPACE indicates that insufficient space is available to store the new string.

Remarks

If you create an owner-drawn combo box with the CBS_SORT style but without the CBS_HASSTRINGS style, the WM_COMPAREITEM message is sent one or more times to the owner of the combo box so the new item can be properly placed in the list.

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

See Also

CB_INSERTSTRING, WM_COMPAREITEM