Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with vertical scrolling in listview

Problem with vertical scrolling in listview

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Vickery
    wrote on last edited by
    #1

    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)

    PJ ArendsP 1 Reply Last reply
    0
    • P Paul Vickery

      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)

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      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

      Within you lies the power for good; Use it!

      P 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        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

        P Offline
        P Offline
        Paul Vickery
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups