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. Another CScrollBar question

Another CScrollBar question

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionhelp
3 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.
  • K Offline
    K Offline
    KellyR
    wrote on last edited by
    #1

    Hi, Mark directed me to the MSDN section about scrollbars this morning which helped a lot, but I still have one problem that I can't seem to solve: Once again I'm using VC++ with MFC, and I have a CScrollBar that I want to use to scroll some custom controls. I don't want to use the dialog's "built-in" scrollbar because it isn't in the right place and I have lots of other bits of data there, so I have a stand-alone CScrollBar control that I have mapped through DDX_Control to my dialog. Since my scrollbar is stand-alone I had to subclass it in order to catch the WM_VSCROLL messages sent to its window when the bar is moved. This all works fine BUT ONLY when I have the scroll bar's style set as WM_VSCROLL. The style SHOULD be SBS_VERT, but when I make the style SBS_VERT instead of WM_VSCROLL, I no longer get any WM_VSCROLL messages in my subclassed process. What could I be doing wrong??? Also on a side note, it seems pretty ridiculous that I have to either subclass the control or overload it and handle OnVScroll explicitly to get the scroll bar to function. Is there a better way? Thanks!

    KR

    M 1 Reply Last reply
    0
    • K KellyR

      Hi, Mark directed me to the MSDN section about scrollbars this morning which helped a lot, but I still have one problem that I can't seem to solve: Once again I'm using VC++ with MFC, and I have a CScrollBar that I want to use to scroll some custom controls. I don't want to use the dialog's "built-in" scrollbar because it isn't in the right place and I have lots of other bits of data there, so I have a stand-alone CScrollBar control that I have mapped through DDX_Control to my dialog. Since my scrollbar is stand-alone I had to subclass it in order to catch the WM_VSCROLL messages sent to its window when the bar is moved. This all works fine BUT ONLY when I have the scroll bar's style set as WM_VSCROLL. The style SHOULD be SBS_VERT, but when I make the style SBS_VERT instead of WM_VSCROLL, I no longer get any WM_VSCROLL messages in my subclassed process. What could I be doing wrong??? Also on a side note, it seems pretty ridiculous that I have to either subclass the control or overload it and handle OnVScroll explicitly to get the scroll bar to function. Is there a better way? Thanks!

      KR

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You can catch the WM_VSCROLL message in the parent of the scrollbar control. There's no reason to subclass the control.

      KellyR wrote:

      ONLY when I have the scroll bar's style set as WM_VSCROLL

      WM_VSCROLL is a message, not a style, so it shouldn't be used as a style :) If you don't specify SBS_VERT as a style, then the default is SBS_HORZ. I tested this real quick - Here's all I did: 1) Added a scrollbar control (vertical) to a dialog 2) Right clicked the control and added a control variable (to the dialog's class) 3) Added a WM_VSCROLL handler to the dialog class. Clicking on the scrollbar control sends a WM_VSCROLL to the parent as expected. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      K 1 Reply Last reply
      0
      • M Mark Salsbery

        You can catch the WM_VSCROLL message in the parent of the scrollbar control. There's no reason to subclass the control.

        KellyR wrote:

        ONLY when I have the scroll bar's style set as WM_VSCROLL

        WM_VSCROLL is a message, not a style, so it shouldn't be used as a style :) If you don't specify SBS_VERT as a style, then the default is SBS_HORZ. I tested this real quick - Here's all I did: 1) Added a scrollbar control (vertical) to a dialog 2) Right clicked the control and added a control variable (to the dialog's class) 3) Added a WM_VSCROLL handler to the dialog class. Clicking on the scrollbar control sends a WM_VSCROLL to the parent as expected. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        K Offline
        K Offline
        KellyR
        wrote on last edited by
        #3

        That's weird, that's the first thing I tried earlier today and it didn't work. I must have done something wrong before because it seems to work now. I thought it was stupid to have to subclass the thing... Ok, all set, thanks!

        KR

        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