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. Handle to scrollbar in CListCtrl

Handle to scrollbar in CListCtrl

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

    How can I get handle to the CScrollBar which is created automatically when I insert enough items to my report-view?

    A 1 Reply Last reply
    0
    • J JussiL

      How can I get handle to the CScrollBar which is created automatically when I insert enough items to my report-view?

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      The CListCtrl is responsible for upkeeping and drawing it's scroll bar. The control itself handles the messages and drawing related to this window item, that is, there is no external control embedded. Or, at least none that I know of. You could use Spy++ to see if you can attach to the scroll bar itself on the control. If you can, then it exists, if you can't, then it's embedded. What is it that you'd need to accomplish using the handle ? To scroll the control ? To draw it yourself ? -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      J 1 Reply Last reply
      0
      • A Antti Keskinen

        The CListCtrl is responsible for upkeeping and drawing it's scroll bar. The control itself handles the messages and drawing related to this window item, that is, there is no external control embedded. Or, at least none that I know of. You could use Spy++ to see if you can attach to the scroll bar itself on the control. If you can, then it exists, if you can't, then it's embedded. What is it that you'd need to accomplish using the handle ? To scroll the control ? To draw it yourself ? -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

        J Offline
        J Offline
        JussiL
        wrote on last edited by
        #3

        I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi

        S A A 3 Replies Last reply
        0
        • J JussiL

          I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi

          S Offline
          S Offline
          Shog9 0
          wrote on last edited by
          #4

          JussiL wrote: What would be a better approach? Can't say, until you describe what you're actually trying to accomplish. :)
          --- the work, which will become a new genre unto itself, will be called...

          1 Reply Last reply
          0
          • J JussiL

            I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            To determine if the window has a scrollbar(s) you can check it's style and look for WS_HSCROLL & WS_VSCROLL. I don't think there is a notification message for the scrollbar create/destroy event, but monitoring all the messages that might cause it should help. WM_SIZE (list view), , WM_NOTIFY: LVN_INSERTITEM, LVN_DELETEITEM (listview parent), HDN_BEGINTRACKA, HDN_BEGINTRACKA (listview). Edward

            J 1 Reply Last reply
            0
            • J JussiL

              I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi

              A Offline
              A Offline
              Antti Keskinen
              wrote on last edited by
              #6

              The best approach by far is to derive a custom control from CListCtrl, then add a CSrollBar member to it and manually create and destroy it as necessary. This allows complete control on how the scroll bar works, but if you are unfamiliar with custom control creation, it might prove somewhat difficult. There is an article available in CodeProject that discusses a list control with it's scroll bars removed. By looking at it's code, you might find some tips or clues on how to implement your solution. Lars Werner's article Hide scrollbars from a CListCtrl[^]. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

              1 Reply Last reply
              0
              • A Anonymous

                To determine if the window has a scrollbar(s) you can check it's style and look for WS_HSCROLL & WS_VSCROLL. I don't think there is a notification message for the scrollbar create/destroy event, but monitoring all the messages that might cause it should help. WM_SIZE (list view), , WM_NOTIFY: LVN_INSERTITEM, LVN_DELETEITEM (listview parent), HDN_BEGINTRACKA, HDN_BEGINTRACKA (listview). Edward

                J Offline
                J Offline
                JussiL
                wrote on last edited by
                #7

                This solution turned out to be the best for me! Since now I just check the style when inserting or deleting items from the listview (this is enough in my case) like this: if ( (GetStyle() & WS_HSCROLL) != 0 ) doMyStuff(); Thanks! -Jussi

                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