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. CListBox and Scrollbar...

CListBox and Scrollbar...

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 4 Posters 1 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.
  • M Offline
    M Offline
    Manfred Ramosch
    wrote on last edited by
    #1

    Does anybody know how to retrieve a WIN-message that indicates the scrollbar of a Listbox having been scrolled up or down? I have a modeless dialog with 6 listboxes (side by side) that get the V-Scrollbar automatically when there are more Items to display than the LBs can show at once. All lists do always have the same lenght due to the behaviour of my data. What I want is to keep the LBs synchron - I mean that the TOPINDEX is the same in all my boxes. Even when I move the scrollbar I wanna keep them in sync. That works fine with the LBN_SELCHANGE for every box: void CMyClass::OnSelchangeList01() { int iResult; iResult = m_List01.GetCurSel(); m_List01.SetCurSel(iResult); m_List02.SetCurSel(iResult); m_List03.SetCurSel(iResult); m_List04.SetCurSel(iResult); m_List05.SetCurSel(iResult); m_List06.SetCurSel(iResult); iResult = m_List01.GetTopIndex(); m_List01.SetTopIndex(); m_List02.SetTopIndex(); m_List03.SetTopIndex(); m_List04.SetTopIndex(); m_List05.SetTopIndex(); m_List06.SetTopIndex(); } The same I do for OnSelchangeList02(); OnSelchangeList03(); OnSelchangeList04(); OnSelchangeList05(); OnSelchangeList06(); I can select whatever I want in whatever LB - with the mouse or the arrow-keys. The TopIndex of every LB is the same and the selected items (highlighted) appear side by side. So far so good - ONLY after moving the vertical scrollbar the LBs are out of sync because I cannot get any message of the scrollbar showing me that the visual state of the LB has changed and though giving me the possibility to use the SetTopIndex()-function like above in the LBN_SELCHANGE message handler of my LBs... I tried it with CWnd::OnVScroll() but I couldn't find a way to retrieve a notification from my Listbox-scrollbars out of this function... All those nice SB_BOTTOM, SB_TOP, SB_THUMBTRACK - and I cannot access them...... So any Ideas out there...? Manfred --- Programming is knowing...

    D L 2 Replies Last reply
    0
    • M Manfred Ramosch

      Does anybody know how to retrieve a WIN-message that indicates the scrollbar of a Listbox having been scrolled up or down? I have a modeless dialog with 6 listboxes (side by side) that get the V-Scrollbar automatically when there are more Items to display than the LBs can show at once. All lists do always have the same lenght due to the behaviour of my data. What I want is to keep the LBs synchron - I mean that the TOPINDEX is the same in all my boxes. Even when I move the scrollbar I wanna keep them in sync. That works fine with the LBN_SELCHANGE for every box: void CMyClass::OnSelchangeList01() { int iResult; iResult = m_List01.GetCurSel(); m_List01.SetCurSel(iResult); m_List02.SetCurSel(iResult); m_List03.SetCurSel(iResult); m_List04.SetCurSel(iResult); m_List05.SetCurSel(iResult); m_List06.SetCurSel(iResult); iResult = m_List01.GetTopIndex(); m_List01.SetTopIndex(); m_List02.SetTopIndex(); m_List03.SetTopIndex(); m_List04.SetTopIndex(); m_List05.SetTopIndex(); m_List06.SetTopIndex(); } The same I do for OnSelchangeList02(); OnSelchangeList03(); OnSelchangeList04(); OnSelchangeList05(); OnSelchangeList06(); I can select whatever I want in whatever LB - with the mouse or the arrow-keys. The TopIndex of every LB is the same and the selected items (highlighted) appear side by side. So far so good - ONLY after moving the vertical scrollbar the LBs are out of sync because I cannot get any message of the scrollbar showing me that the visual state of the LB has changed and though giving me the possibility to use the SetTopIndex()-function like above in the LBN_SELCHANGE message handler of my LBs... I tried it with CWnd::OnVScroll() but I couldn't find a way to retrieve a notification from my Listbox-scrollbars out of this function... All those nice SB_BOTTOM, SB_TOP, SB_THUMBTRACK - and I cannot access them...... So any Ideas out there...? Manfred --- Programming is knowing...

      D Offline
      D Offline
      Daniel Ferguson
      wrote on last edited by
      #2

      Maybe you could use a multi-column list? Daniel "das leid schlaft in der maschine" -Einstürzende Neubauten

      1 Reply Last reply
      0
      • M Manfred Ramosch

        Does anybody know how to retrieve a WIN-message that indicates the scrollbar of a Listbox having been scrolled up or down? I have a modeless dialog with 6 listboxes (side by side) that get the V-Scrollbar automatically when there are more Items to display than the LBs can show at once. All lists do always have the same lenght due to the behaviour of my data. What I want is to keep the LBs synchron - I mean that the TOPINDEX is the same in all my boxes. Even when I move the scrollbar I wanna keep them in sync. That works fine with the LBN_SELCHANGE for every box: void CMyClass::OnSelchangeList01() { int iResult; iResult = m_List01.GetCurSel(); m_List01.SetCurSel(iResult); m_List02.SetCurSel(iResult); m_List03.SetCurSel(iResult); m_List04.SetCurSel(iResult); m_List05.SetCurSel(iResult); m_List06.SetCurSel(iResult); iResult = m_List01.GetTopIndex(); m_List01.SetTopIndex(); m_List02.SetTopIndex(); m_List03.SetTopIndex(); m_List04.SetTopIndex(); m_List05.SetTopIndex(); m_List06.SetTopIndex(); } The same I do for OnSelchangeList02(); OnSelchangeList03(); OnSelchangeList04(); OnSelchangeList05(); OnSelchangeList06(); I can select whatever I want in whatever LB - with the mouse or the arrow-keys. The TopIndex of every LB is the same and the selected items (highlighted) appear side by side. So far so good - ONLY after moving the vertical scrollbar the LBs are out of sync because I cannot get any message of the scrollbar showing me that the visual state of the LB has changed and though giving me the possibility to use the SetTopIndex()-function like above in the LBN_SELCHANGE message handler of my LBs... I tried it with CWnd::OnVScroll() but I couldn't find a way to retrieve a notification from my Listbox-scrollbars out of this function... All those nice SB_BOTTOM, SB_TOP, SB_THUMBTRACK - and I cannot access them...... So any Ideas out there...? Manfred --- Programming is knowing...

        L Offline
        L Offline
        l a u r e n
        wrote on last edited by
        #3

        surely you can put an ON_NOTIFY() handler for the WM_VSCROLL message? :suss: --- "every year we invent better idiot proof systems and every year they invent better idiots"

        M 1 Reply Last reply
        0
        • L l a u r e n

          surely you can put an ON_NOTIFY() handler for the WM_VSCROLL message? :suss: --- "every year we invent better idiot proof systems and every year they invent better idiots"

          M Offline
          M Offline
          Manfred Ramosch
          wrote on last edited by
          #4

          Listbox Notification works only if a list item has been clicked or double-clicked... Or show me exactly what you mean...!?! :confused: Manfred --- Programming is knowing...

          L 1 Reply Last reply
          0
          • M Manfred Ramosch

            Listbox Notification works only if a list item has been clicked or double-clicked... Or show me exactly what you mean...!?! :confused: Manfred --- Programming is knowing...

            L Offline
            L Offline
            l a u r e n
            wrote on last edited by
            #5

            hmmmmmm i been messing about for a few hours and it seems you're right ... duhhh ... well at least i can't get it to notify me either ... sheesh ... i wonder if mfc doesn't let that message get 'out of the box' so to speak sorry :( --- "every year we invent better idiot proof systems and every year they invent better idiots"

            L 1 Reply Last reply
            0
            • L l a u r e n

              hmmmmmm i been messing about for a few hours and it seems you're right ... duhhh ... well at least i can't get it to notify me either ... sheesh ... i wonder if mfc doesn't let that message get 'out of the box' so to speak sorry :( --- "every year we invent better idiot proof systems and every year they invent better idiots"

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I got the same problem too. I try to resolve it by disable the scroll bar in CListBox,and insert a CScrollBar to control all CListBoxes. But, very weird is that I can not see any usable message for scrollbar in ClassWizard!? Does anybody know why? How could I control a Scroll bar? I really need help!:(

              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