CB_INSERTSTRING

3.0

CB_INSERTSTRING
wParam = (WPARAM) index;            /* item index                  */
lParam = (LPARAM) (LPCSTR) lpsz;    /* address of string to insert */

An application sends a CB_INSERTSTRING message to insert a string into the list box of a combo box. Unlike the CB_ADDSTRING message, the CB_INSERTSTRING message does not cause a list with the CBS_SORT style to be sorted.

Parameters

index

Value of wParam. Specifies the zero-based index of the position at which to insert the string. If this parameter is –1, the string is added to the end of the list.

lpsz

Value of lParam. Points to the null-terminated string that is to be inserted. 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 index of the position at which the string was inserted. 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.

Example

This example inserts the string “my string” into the third position in the list box of a combo box:

SendDlgItemMessage(hdlg, ID_MYCOMBOBOX,
    CB_INSERTSTRING, 2, (LPARAM) ((LPCSTR) "my string"));

See Also

CB_ADDSTRING