partially visible by doing modulo...
nPage is the number that is passed to OnVScroll when the user pages
up
and
down, it can be anything you want, 5 is the typcial number of items
that
you
would scroll when the user pages up or down.
The list control will automatically show and hide its scrollbar
depending
on
the number of items in it, and it does it very cleanly. It sounds
like
that
is what you are trying to do. Is it not?
What the article was talking about was that if you disable the
scrollbar
of
a list control using the "No Scroll" option of the list control,
and
the
list control has enough items that would need scrolling you would
not
be
able to scroll these items. Which is true, for example if you have
a
listbox and you disable its scrollbar while there are enough items
to
scroll
up and down you can still scroll by using the keyboard or clicking
and
dragging inside the listbox. That is not the case with a list
control.
But
if you want to display a scrollbar when the user can scroll, and
hide
it
when there isn't enough items to scroll then it does that
automatically.
Now if you are doing this to get rid of the horizontal scrollbar
then
all
of
this changes, but there are ways around that, like making your last
column
be auto fit, so that it resizes itself in order to fit and not
cause a
horizontal scrollbar to show up.
AliR.
"Erakis" <Erakis@discussions.microsoft.com> wrote in message
news:29241AA6-AC8D-4D27-B7BC-22D0839677BC@microsoft.com...
I'm creating a list type control of my own, derived from CWnd.
I just wanted to confirm you that hiding scrollbar from a
CListCtrl
is
kind
of pain. Because we need to get and set rect of the list, cells
and
this
solution corrupt those information. Also we need to daw image on
specific
rows, custom headers drawing, transparent background, etc...
By the way, my own list is almost terminated and it is working. I
just
wanted to set up CORRECTLY my scrollbar and not doing it no
matter
how...
And what should be the value of nPage ?
Martin
"AliR (VC++ MVP)" wrote:
You would normally hide the scrollbar when the number of items
is
less
than
or equal to the number of visible items! What does that have to
do
with
anything.
I'm confused, your original message said that you want to setup
scrollbars
for your custom list control. Are you using a CListCtrl or are
you
creating
a list type control of your own?
The article you pointed me to shows how to cleanly remove
scrollbars
from
CListCtrl.
What does this solution does not work well with our project
really
mean?
What part of what does not work well?
m_iRowCount - 1 is not correct, m_iRowCount - NumVisible would
be
the
max
number of items you want to scroll.
AliR.
"Erakis" <Erakis@discussions.microsoft.com> wrote in message
news:B2322101-19A2-4AC8-9DC3-539510766257@microsoft.com...
Because I need to HIDE scrollbar. Here is the explanation of
what
I'm
talking
about.
http://lars.werner.no/?page_id=24
But this solution does not working well for our project on
Windows
CE
5.
I was reading an exemple on how to scroll bitmap image and
they
were
setting
nMax to bitmap.cy. So this is why I set nMax to m_iRowCount -
1.
But thank you for your tips, It is really appreciated ;)
"AliR (VC++ MVP)" wrote:
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);
...
}