Click to See Complete Forum and Search --> : ListView Scrollbar


May 14th, 1999, 10:48 AM
I was hoping for a little help on this problem. I have ListView control in a child window. Each line in the ListView contains one string. I am trying to create a function that will center the ListView on a specific line. Here is the function:

void CCodeList::CenterOn(U_LONG CenterLineNum)
{
BOOL test;
SCROLLINFO si;

m_ListCtrl.GetScrollInfo(SB_VERT, &si, SIF_ALL);

if (CenterLineNum > si.nMax - (si.nPage/2))
{
si.nPos = si.nMax - si.nPage;
}
else if (CenterLineNum < si.nPage/2)
{
si.nPos = 0;
}
else
{
si.nPos = CenterLineNum - si.nPage/2;
}
si.fMask = SIF_POS;
test = SetScrollInfo(SB_VERT, &si, TRUE);
}

Whenever I run this the List View does not move. The lines and the scrollbar both stay where they are. What Am I missing here? Thanks in advance.
Rob