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.
index
Value of wParam. Specifies the zero-based index of the item in the list box.
The return value is LB_ERR if an error occurs.
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.
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);