Scrollbar set up



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
.



Relevant Pages

  • Re: Scrollbar set up
    ... I was reading an exemple on how to scroll bitmap image and they were setting ... CRect rectZoneVisible; ... GetClientRect(&rectZoneVisible); ... GetClientRowRect(0, &rowRect); ...
    (microsoft.public.vc.mfc)
  • Re: Scrollbar set up
    ... Max to the number of items that you want to scroll, ... CRect rectZoneVisible; ... GetClientRect(&rectZoneVisible); ... GetClientRowRect(0, &rowRect); ...
    (microsoft.public.vc.mfc)
  • Re: Scrollbar set up
    ... I was reading an exemple on how to scroll bitmap image and they were ... number of items in your list minus the number of visible items. ... GetClientRect(&rectZoneVisible); ... GetClientRowRect(0, &rowRect); ...
    (microsoft.public.vc.mfc)
  • Re: Are the scroll bar present???
    ... I think You can campare the values of GetWindowRectand GetClientRect() to determine if scrollbars are present or not. ... >I am trying to determine whether or not the scroll bars are present when I ... >List control scroll bars disappear when the width of all the columns fit ...
    (microsoft.public.vc.mfc)