Scrollbar set up
- From: Erakis <Erakis@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 6 Sep 2008 22:32:28 -0700
Hi,
I want to make a kind of list view by myself. Including column and rows. I
need scrollbar fonctionnality but I'm stuck on how set up it.
For vertical scrolling I want that scrollbar scroll by item and not by
pixel. Here is how I think it could be :
// Get client rect
CRect rectZoneVisible;
GetClientRect( &rectZoneVisible );
if ( m_iRowCount > 0 )
{
// Get column rect
CRect colRect;
GetClientColumnRect( 0, &colRect );
// Get first row rect
CRect rowRect;
GetClientRowRect( 0, &rowRect );
// Check vertical scroll bar visibility
if ( (m_iRowCount * rowRect.Height()) > rectZoneVisible.Height() -
colRect.Height() )
{
// Show vertical scroll bar et set up it
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nPos = m_ScrollBarHiddenV.GetScrollPos();
si.nMin = 0;
si.nMax = m_iRowCount - 1;
si.nPage = rectZoneVisible.Height() / rowRect.Height();
si.nTrackPos = 0;
m_ScrollBarHiddenV.SetScrollInfo( &si, TRUE );
m_ScrollBarHiddenV.ShowScrollBar(TRUE);
...
}
else
{
m_ScrollBarHiddenV.ShowScrollBar(FALSE);
}
}
First of all thing seem to be correct but I don't understand why.
Why nMax = m_iRowCount - 1 and not simply nMax = m_iRowCount ?
Secondly if nPage may have the number of item per page so why itsn't :
nPage = (rectZoneVisible.Height() - colRect.Height()) / rowRect.Height();
Because column height must be subtracted from client zone before dividing by
rowRect ?
Can someone help me to understand ?
Best regards
.
- Follow-Ups:
- Re: Scrollbar set up
- From: AliR \(VC++ MVP\)
- Re: Scrollbar set up
- Prev by Date: Re: My program not visible using Remote Desktop.
- Next by Date: Re: Question Concerning Visual C++ 6.0
- Previous by thread: Question Concerning Visual C++ 6.0
- Next by thread: Re: Scrollbar set up
- Index(es):
Relevant Pages
|