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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to detect scrollbars (horizontal) in CListCtrl?

how to detect scrollbars (horizontal) in CListCtrl?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
6 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.
  • N Offline
    N Offline
    nss
    wrote on last edited by
    #1

    I need to change the height of my CListCtrl when scrollbars are not present (horizontally). How can I , on the fly detect if the control has scrollbars or not? its columns keep changing so sometimes thee is a scrollbar, and sometimes not... Thanks, ns

    V RaviBeeR 2 Replies Last reply
    0
    • N nss

      I need to change the height of my CListCtrl when scrollbars are not present (horizontally). How can I , on the fly detect if the control has scrollbars or not? its columns keep changing so sometimes thee is a scrollbar, and sometimes not... Thanks, ns

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      One solution is to add messages handlers for both horizontal scroll bar and vertical scroll bar. WM_HSCROLL - OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) WM_VSCROLL - OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) Kuphryn

      1 Reply Last reply
      0
      • N nss

        I need to change the height of my CListCtrl when scrollbars are not present (horizontally). How can I , on the fly detect if the control has scrollbars or not? its columns keep changing so sometimes thee is a scrollbar, and sometimes not... Thanks, ns

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        Accumulate the width of each column. If the total exceeds the list control's client area's width, you've got scrollbars. Use GetColumn() to get the column widths and GetClientRect() to get the client rect. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

        N 1 Reply Last reply
        0
        • RaviBeeR RaviBee

          Accumulate the width of each column. If the total exceeds the list control's client area's width, you've got scrollbars. Use GetColumn() to get the column widths and GetClientRect() to get the client rect. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

          N Offline
          N Offline
          nss
          wrote on last edited by
          #4

          Thanks for the ideas....its a funny problem. When there are sbars, I've shrunk the control down so all you see are the headers and the scrollbar. When there arent enough columns populated, the sb vanishes, and the area it took up, is visible to the user because now the first row of the control shows. I have to make it somehow that it doesnt get this blank area...only the header should show.

          RaviBeeR 1 Reply Last reply
          0
          • N nss

            Thanks for the ideas....its a funny problem. When there are sbars, I've shrunk the control down so all you see are the headers and the scrollbar. When there arent enough columns populated, the sb vanishes, and the area it took up, is visible to the user because now the first row of the control shows. I have to make it somehow that it doesnt get this blank area...only the header should show.

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Hmm, you could try using one of SPI_ constants (none seemed obvious) in GetSystemMetrics() to get the height of the list control's header control, and use this value to resize the control. Alternatively, you could just hide the list control and show a dummy one (of fixed height) with the same columns. But if you want my honest opinion :) the concept of a list control that changes its height seems suspect at first glance. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

            N 1 Reply Last reply
            0
            • RaviBeeR RaviBee

              Hmm, you could try using one of SPI_ constants (none seemed obvious) in GetSystemMetrics() to get the height of the list control's header control, and use this value to resize the control. Alternatively, you could just hide the list control and show a dummy one (of fixed height) with the same columns. But if you want my honest opinion :) the concept of a list control that changes its height seems suspect at first glance. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

              N Offline
              N Offline
              nss
              wrote on last edited by
              #6

              This part is a real pain, I'm just tossing about ideas. It uses a CP class, and it does okay sort of but not really. Like I repopulate the ctrl each time with new headers and data (new # of columns) . Somethings going horribly wrong with my logic, and I'm staring at it.....aaargh! Thanks for your ideas though. Soon as the functionality works, I'l apply the cosmetic part..:)

              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