LB_ADDSTRING
wParam = 0; /* not used, must be zero */
lParam = (LPARAM) (LPCSTR) lpsz; /* address of string to add */
An application sends an LB_ADDSTRING message to add a string to a list box. If the list 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.
lpsz
Value of lParam. Points to the null-terminated string that is to be added. If the list box was created with an owner-drawn style but without the LBS_HASSTRINGS style, the value of the lpsz parameter is stored rather than the string it would otherwise point to.
The return value is the zero-based index to the string in the list box. The return value is LB_ERR if an error occurs; the return value is LB_ERRSPACE if insufficient space is available to store the new string.
If an owner-drawn list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the WM_COMPAREITEM message is sent one or more times to the owner of the list box so the new item can be properly placed in the list box.
This example adds the string “my string” to a list box:
DWORD dwIndex;
dwIndex = SendDlgItemMessage(hdlg, ID_MYLISTBOX,
LB_ADDSTRING, 0, (LPARAM) ((LPCSTR) "my string"));