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. Maximum size of scrollbars

Maximum size of scrollbars

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 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.
  • P Offline
    P Offline
    pgrohs
    wrote on last edited by
    #1

    Does anyone know an easy way to overcome the problem with the SRT_MAX limit of scrollbars? :confused: -- modified at 12:08 Tuesday 7th March, 2006

    G 1 Reply Last reply
    0
    • P pgrohs

      Does anyone know an easy way to overcome the problem with the SRT_MAX limit of scrollbars? :confused: -- modified at 12:08 Tuesday 7th March, 2006

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      Use SetScrollInfo()[^].


      Software Zen: delete this;

      Fold With Us![^]

      P 1 Reply Last reply
      0
      • G Gary R Wheeler

        Use SetScrollInfo()[^].


        Software Zen: delete this;

        Fold With Us![^]

        P Offline
        P Offline
        pgrohs
        wrote on last edited by
        #3

        This is my code: void CEditor::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { SCROLLINFO ScrollInfo; ScrollInfo.cbSize = sizeof(SCROLLINFO); ScrollInfo.fMask = SIF_POS | SIF_RANGE; GetScrollInfo(SB_VERT, &ScrollInfo); switch(nSBCode){ ... case SB_THUMBPOSITION: ScrollInfo.nPos = nPos; break; case SB_THUMBTRACK: ScrollInfo.nPos = nPos; break; } SetVScroll(ScrollInfo.nPos); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); } The problem is that nPos does not become bigger than SRT_MAX. This is because nPos comes from the high-order word of the wParam of the message WM_VSCROLL. So it is just a short value that is casted to an integer. Is there another way to get the current position of the scroll box? Thanks

        G 1 Reply Last reply
        0
        • P pgrohs

          This is my code: void CEditor::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { SCROLLINFO ScrollInfo; ScrollInfo.cbSize = sizeof(SCROLLINFO); ScrollInfo.fMask = SIF_POS | SIF_RANGE; GetScrollInfo(SB_VERT, &ScrollInfo); switch(nSBCode){ ... case SB_THUMBPOSITION: ScrollInfo.nPos = nPos; break; case SB_THUMBTRACK: ScrollInfo.nPos = nPos; break; } SetVScroll(ScrollInfo.nPos); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); } The problem is that nPos does not become bigger than SRT_MAX. This is because nPos comes from the high-order word of the wParam of the message WM_VSCROLL. So it is just a short value that is casted to an integer. Is there another way to get the current position of the scroll box? Thanks

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          You have to initialize the scroll bar at some point with a call to SetScrollInfo. My guess would be you want to do this in your CEditor::OnCreate handler. The nPos value you are seeing in your OnVScroll handler varies between the values of nMin and nMax in the SCROLLINFO structure.


          Software Zen: delete this;

          Fold With Us![^]

          P 1 Reply Last reply
          0
          • G Gary R Wheeler

            You have to initialize the scroll bar at some point with a call to SetScrollInfo. My guess would be you want to do this in your CEditor::OnCreate handler. The nPos value you are seeing in your OnVScroll handler varies between the values of nMin and nMax in the SCROLLINFO structure.


            Software Zen: delete this;

            Fold With Us![^]

            P Offline
            P Offline
            pgrohs
            wrote on last edited by
            #5

            Thank you for your help, but I think I have to describe the problem more detailed. The scrollbar works fine when I move the scroll box with SB_PAGEDOWN or SB_LINEDOWN because in this case I do not need nPos. But when I react on SB_THUMBTRACK or SB_THUMBPOSITION I need nPos. So when I move the scroll box with the mouse to a position that is bigger than SRT_MAX nPos becomes zero and the scroll box jumps back to the top. Again: this is only the case if the scroll box is directly moved with the mouse. When I click on the scroll arrows everything works fine. So what I need is a way to find out where the user has moved the scroll box when it is above SRT_MAX. Thanks

            G 1 Reply Last reply
            0
            • P pgrohs

              Thank you for your help, but I think I have to describe the problem more detailed. The scrollbar works fine when I move the scroll box with SB_PAGEDOWN or SB_LINEDOWN because in this case I do not need nPos. But when I react on SB_THUMBTRACK or SB_THUMBPOSITION I need nPos. So when I move the scroll box with the mouse to a position that is bigger than SRT_MAX nPos becomes zero and the scroll box jumps back to the top. Again: this is only the case if the scroll box is directly moved with the mouse. When I click on the scroll arrows everything works fine. So what I need is a way to find out where the user has moved the scroll box when it is above SRT_MAX. Thanks

              G Offline
              G Offline
              Gary R Wheeler
              wrote on last edited by
              #6

              When handling SB_THUMBTRACK, you need to look at the nTrackPos member of the SCROLLINFO structure, not nPos.


              Software Zen: delete this;

              Fold With Us![^]

              P 1 Reply Last reply
              0
              • G Gary R Wheeler

                When handling SB_THUMBTRACK, you need to look at the nTrackPos member of the SCROLLINFO structure, not nPos.


                Software Zen: delete this;

                Fold With Us![^]

                P Offline
                P Offline
                pgrohs
                wrote on last edited by
                #7

                Thank you very much. It works. MSDN is such a great thing, but it happens the you do not to see the wood for the trees.:rolleyes:

                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