LB_SETTOPINDEX

3.0

LB_SETTOPINDEX
wParam = (WPARAM) index;        /* item index             */
lParam = 0L;                    /* not used, must be zero */

An application sends an LB_SETTOPINDEX message to ensure that a particular item in a list box is visible.

Parameters

index

Value of wParam. Specifies the zero-based index of the item in the list box.

Return Value

The return value is LB_ERR if an error occurs.

Comments

The system scrolls the list box so that either the specified item appears at the top of the list box or the maximum scroll range has been reached.

Example

This example searches for an item in a list box that matches the string “my string” and, if a match is found, ensures that the item is visible:

int iIndex;


iIndex = (int) SendMessage(hMyListbox, LB_FINDSTRING, -1,
    (LPARAM) (LPCSTR) "my string");

if (iIndex != LB_ERR)
  SendMessage(hMyListbox, LB_SETTOPINDEX, (WPARAM) iIndex, 0L);

See Also

LB_GETTOPINDEX