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