Because I need to HIDE scrollbar. Here is the explanation of what I'm
about.
But this solution does not working well for our project on Windows CE 5.
nMax to bitmap.cy. So this is why I set nMax to m_iRowCount - 1.
If it was me I would turn on the windows scrollbar, set the min to 0 and
the
Max to the number of items that you want to scroll, which would be total
number of items in your list minus the number of visible items.
Next add a TopItemIndex member to your class, which indicates which item
is
the first being displayed, initialize to zero.
Then catch the WM_VSCROLL message (OnVScroll)
For every scroll down add one to your TopItemIndex and redraw, for every
scroll up subtract one and then redraw. You can also handle page up and
page down and thumb tracking that way.
Your paint method will need to take the TopItemIndex into account and
draw
that item as the first item in the list.
AliR.
P.S. Why do all this when you can do owner draw list controls and
listboxs?
"Erakis" <Erakis@discussions.microsoft.com> wrote in message
news:0BC041AE-75B5-4011-BDF9-51675A45599B@microsoft.com...
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