Export (0) Print
Expand All

CListBox::GetTopIndex 

Retrieves the zero-based index of the first visible item in a list box.


int GetTopIndex( ) const;

The zero-based index of the first visible item in a list box if successful, LB_ERR otherwise.

Initially, item 0 is at the top of the list box, but if the list box is scrolled, another item may be at the top.

// The pointer to my list box.
extern CListBox* pmyListBox;

// Want an item in the bottom half to be the first visible item.
int n = pmyListBox->GetCount()/2;
if (pmyListBox->GetTopIndex() < n)
{
   pmyListBox->SetTopIndex(n);
   ASSERT(pmyListBox->GetTopIndex() == n);
}

Community Additions

ADD
Show:
© 2014 Microsoft