CB_GETCURSEL

3.0

CB_GETCURSEL
wParam = 0;     /* not used, must be zero */
lParam = 0L;    /* not used, must be zero */

An application sends a CB_GETCURSEL message to retrieve the index of the currently selected item, if any, in the list box of a combo box.

Parameters

This message has no parameters.

Return Value

The return value is the zero-based index of the currently selected item, or it is CB_ERR if no item is selected.

Example

This example retrieves the index of the currently selected string in the list box of a combo box and then retrieves that string:

char szBuf[20];
DWORD dwIndex;

dwIndex = SendDlgItemMessage(hdlg, ID_MYCOMBOBOX, CB_GETCURSEL, 0, 0);
if (dwIndex != CB_ERR)
    SendDlgItemMessage(hdlg, ID_MYCOMBOBOX,
        CB_GETLBTEXT, (WPARAM) dwIndex, (LPARAM) ((LPCSTR) szBuf));

See Also

CB_SETCURSEL