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. CScrollBar: what's the secret?

CScrollBar: what's the secret?

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiodebuggingbeta-testinghelp
5 Posts 2 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
    Jamaica
    wrote on last edited by
    #1

    I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!

    J C 2 Replies Last reply
    0
    • J Jamaica

      I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!

      J Offline
      J Offline
      Jamaica
      wrote on last edited by
      #2

      What's more, in the resources, the scrollbars show in a nice Windows XP style. When the app runs, they are flat and ugly. Hmmm. If there is someone out there that can take 5 mins to do this in both VS 2005 Beta and VS 2003, and find that I'm beating my head against a bug in VS 2005 Beta, that would at least be partial relief!

      1 Reply Last reply
      0
      • J Jamaica

        I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Jamaica wrote:

        But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?

        The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired. Christian Graus - Microsoft MVP - C++

        J 1 Reply Last reply
        0
        • C Christian Graus

          Jamaica wrote:

          But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?

          The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired. Christian Graus - Microsoft MVP - C++

          J Offline
          J Offline
          Jamaica
          wrote on last edited by
          #4

          What you say is all true... but has not advanced my cause :( There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....

          C 1 Reply Last reply
          0
          • J Jamaica

            What you say is all true... but has not advanced my cause :( There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Jamaica wrote:

            What you say is all true... but has not advanced my cause

            *grin* I'm sorry, without looking at the code, that's about all could offer.

            Jamaica wrote:

            There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves.

            I have vs2005 final, and I created an MFC app, added a scroll bar and a message handler, and it fired fine. Why don't you create a new app that just does those things and see if it works ? Christian Graus - Microsoft MVP - C++

            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