Problem with vertical scrolling in listview
-
Hi, I have a ListView in which I have used WM_NCCALCSIZE to give me an area at the top where I can draw my own info (above the header). This is fine except that it messes up the vertical scrolling. The last list item (in report view) doesn't appear. (My additional NC area is about 18 pixels high, which is about the height of one item.) It seems that the ListView still thinks its client area is the original size, and so does not allow scrolling down as far as the last line. I have tried using SetScrollInfo to increase its max scroll point, and this works in that I can click down and see the last line appear, but on releasing the mouse, it jumps back up a line, and reverts to the original scroll-bar behaviour. Does anyone have any ideas on how I can fix this? (If I apply the same code to other types of control they work fine, it's just listviews that don't.) Thanks, Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
-
Hi, I have a ListView in which I have used WM_NCCALCSIZE to give me an area at the top where I can draw my own info (above the header). This is fine except that it messes up the vertical scrolling. The last list item (in report view) doesn't appear. (My additional NC area is about 18 pixels high, which is about the height of one item.) It seems that the ListView still thinks its client area is the original size, and so does not allow scrolling down as far as the last line. I have tried using SetScrollInfo to increase its max scroll point, and this works in that I can click down and see the last line appear, but on releasing the mouse, it jumps back up a line, and reverts to the original scroll-bar behaviour. Does anyone have any ideas on how I can fix this? (If I apply the same code to other types of control they work fine, it's just listviews that don't.) Thanks, Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
Just a wild guess here. Could it be that the list view expects to only have a CHeaderCtrl at the top, and adjusts its scrolling only based on the header control. How about making the CHeaderCtrl ownerdraw and adding the extra space to the header instead of the list control itself?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
Just a wild guess here. Could it be that the list view expects to only have a CHeaderCtrl at the top, and adjusts its scrolling only based on the header control. How about making the CHeaderCtrl ownerdraw and adding the extra space to the header instead of the list control itself?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
I think it must be something to do with that, though turning off the header doesn't make it any better. You can try it easily by subclassing a ListView control, then handling WM_NCCALCSIZE and adding something like lpncsp->rgrc[0].top += 20; Now, add a load of items to the list, and you will see that the vertical scroll-bar doesn't allow you to scroll right to the bottom of the client area. The bottom items get clipped. I can't find any way of telling the ListView how big to consider its client area to be. The closest I have to a solution is to fiddle the scroll bars on scrolling: SCROLLINFO si = { sizeof(si), SIF_RANGE }; m_pList->GetScrollInfo(SB_VERT, &si); si.nMax = m_pList->SendMessage(LVM_GETITEMCOUNT); m_pList->SetScrollInfo(SB_VERT, &si); This allows me to scroll to the bottom, and shows me the bottom item when scrolling, but on releasing the mouse button it jumps back up one notch. I know you like a challenge, and will no doubt find me a solution! :cool:
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)