LB_GETCURSEL
wParam = 0; /* not used, must be zero */
lParam = 0L; /* not used, must be zero */
An application sends an LB_GETCURSEL message to retrieve the index of the currently selected item, if any, in a single-selection list box.
This message has no parameters.
The return value is the zero-based index of the currently selected item. It is LB_ERR if no item is currently selected.
An application should use the LB_GETCARETINDEX to retrieve the index of the item that has the focus rectangle in a multiple-selection list box.
The LB_GETCURSEL message cannot be sent to a multiple-selection list box.
This example retrieves the index of the currently selected string in a list box and then retrieves that string:
char szBuf[20];
DWORD dwIndex;
dwIndex = SendDlgItemMessage(hdlg, ID_MYLISTBOX, LB_GETCURSEL, 0, 0);
if (dwIndex != LB_ERR)
SendDlgItemMessage(hdlg, ID_MYLISTBOX,
LB_GETTEXT, (WPARAM) dwIndex, (LPARAM) ((LPCSTR) szBuf));