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. vertically scrolling a listbox

vertically scrolling a listbox

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 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.
  • C Offline
    C Offline
    CaesarCZ
    wrote on last edited by
    #1

    hello there, I would like to scroll my CListBox (in other words, not a CListCtrl or CListView!) so that a certain item is the topmost visible item in the list (having it visible is not enough). Any ideas? I tried SetScrollPos, and although the range is meaningful, only the scrollbar gets "scrolled" (the bar moves), but the listbox itself doesn't move. I'm getting quite desperate and all i can find if horizontal scrolling everywhere. thanks

    Steve EcholsS P 2 Replies Last reply
    0
    • C CaesarCZ

      hello there, I would like to scroll my CListBox (in other words, not a CListCtrl or CListView!) so that a certain item is the topmost visible item in the list (having it visible is not enough). Any ideas? I tried SetScrollPos, and although the range is meaningful, only the scrollbar gets "scrolled" (the bar moves), but the listbox itself doesn't move. I'm getting quite desperate and all i can find if horizontal scrolling everywhere. thanks

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      I think SetTopIndex or LB_SETTOPINDEX will do what you want.


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      1 Reply Last reply
      0
      • C CaesarCZ

        hello there, I would like to scroll my CListBox (in other words, not a CListCtrl or CListView!) so that a certain item is the topmost visible item in the list (having it visible is not enough). Any ideas? I tried SetScrollPos, and although the range is meaningful, only the scrollbar gets "scrolled" (the bar moves), but the listbox itself doesn't move. I'm getting quite desperate and all i can find if horizontal scrolling everywhere. thanks

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        After you call SetScrollPos() to set the postion of the scroll bar you have to also send a WM_VSCROLL message to the list box to actually get the list box content to scroll.

        pListBox->SetScrollPos(SB_VERT, Position);
        pListBox->SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, Position), NULL);


        You may be right
        I may be crazy
        -- Billy Joel --

        Within you lies the power for good, use it!!!

        C 1 Reply Last reply
        0
        • P PJ Arends

          After you call SetScrollPos() to set the postion of the scroll bar you have to also send a WM_VSCROLL message to the list box to actually get the list box content to scroll.

          pListBox->SetScrollPos(SB_VERT, Position);
          pListBox->SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, Position), NULL);


          You may be right
          I may be crazy
          -- Billy Joel --

          Within you lies the power for good, use it!!!

          C Offline
          C Offline
          CaesarCZ
          wrote on last edited by
          #4

          wonderful, both approaches work. Thanks

          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