An application sends an LB_INSERTSTRING message to insert a string into a list box. Unlike the LB_ADDSTRING message, the LB_INSERTSTRING message does not cause a list with the LBS_SORT style to be sorted.
LB_INSERTSTRING
wParam = (WPARAM) index; // item index
lParam = (LPARAM) (LPCTSTR) lpsz; // address of string to insert
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.
Windows 95: The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a listbox is limited only by available memory.
lpsz
Value of lParam. Points to the null-terminated string to be inserted.
If you create the list box with an owner-drawn style but without the LBS_HASSTRINGS style, the value of the lpsz parameter is stored as item data instead of the string it would otherwise point to. You can send the LB_GETITEMDATA and LB_SETITEMDATA messages to retrieve or modify the item data.
Return Values
The return value is the index of the position at which the string was inserted. If an error occurs, the return value is LB_ERR. If there is insufficient space to store the new string, the return value is LB_ERRSPACE.
See Also