Click to See Complete Forum and Search --> : How to scroll the client area of a CListBox ?


stepfa
June 7th, 1999, 07:53 AM
How can i automatically scroll the cleint area of a CListBox ?

The problem occurs every time the method "DeleteString()" of the CListBox is called.
The method scrolls the client area back to the top of the ListBox.
So i have to scroll it back where it was before "DeleteString()".
SetScrollPos(..) only sets the position of the scroll bar (the thumb) but it doesn´t scroll the client area of the CListBox.
The best way would be to diasble scrolling to the top at the end of "DeleteString()".
If this is not possible i have to reset the old positon of the client area.
But how ?

MfG stepfa

ChrisD
June 7th, 1999, 09:20 AM
int nIndex = lb.GetTopIndex();
if (nIndex != LB_ERR)
{
if (nIndexToDelete <= nIndex)
nIndex--; // Adjust it so the same item stays selected
}
lb.DeleteString(nIndextoDelete);
lb.SetTopIndex(nIndex);


HTH,
Chris