[comp.windows.ms.programmer] Scroll Bars in Child Windows

press@venice.SEDD.TRW.COM (Barry Press) (05/26/91)

I've setup a child window with a horizontal scroll bar, and am now trying to
make the scroll bar do something.  Unfortunately, what I get are not
WM_HSCROLL messages to the child window, but WM_SYSCOMMAND messages with
wParam set to SC_HSCROLL.  lParam appears to be the mouse coordinates.

This is, of course, not terribly useful, as the SB_* type information doesn't
seem to be present.  I checked everywhere I could think of in volume 1 of
the SDK reference, in the guide to programming, and in Petzold.  No joy.

Has anyone experience with scroll bars in child windows?  Is there a way to
do something useful with the resulting WM_SYSCOMMAND?

Thanks.


-- 
Barry Press                                 Internet: press@venice.sedd.trw.com

bonneau@hyper.hyper.com (Paul Bonneau) (05/29/91)

In article <1109@venice.SEDD.TRW.COM> press@venice.sedd.trw.com (Barry Press) writes:
>I've setup a child window with a horizontal scroll bar, and am now trying to
>make the scroll bar do something.  Unfortunately, what I get are not
>WM_HSCROLL messages to the child window, but WM_SYSCOMMAND messages with
>wParam set to SC_HSCROLL.  lParam appears to be the mouse coordinates.
>
I would guess that you are not calling DefWindowProc() when
you get the WM_SYSCOMMAND message.  It think he generates a
WM_HSCROLL message in response.

If all else fails, you can try creating a child ScrollBar
control from within your child window.  The difference is not
much, just an extra call to CreateWindow() instead of using
the WS_HSCROLL style (and getting a non-client area ScrollBar
as a result).

cheers - Paul Bonneau.

press@venice.SEDD.TRW.COM (Barry Press) (05/29/91)

In article <1991May28.193958.9492@hyper.hyper.com> bonneau@hyper.UUCP (Paul Bonneau,,) writes:
>In article <1109@venice.SEDD.TRW.COM> press@venice.sedd.trw.com (Barry Press) writes:
>>I've setup a child window with a horizontal scroll bar, and am now trying to
>>make the scroll bar do something.  Unfortunately, what I get are not
>>WM_HSCROLL messages to the child window, but WM_SYSCOMMAND messages with
>>wParam set to SC_HSCROLL.  lParam appears to be the mouse coordinates.
> ... A lot of useful suggestions deleted ...

I want to thank everyone who replied, many of which I could not send back
to from my site for some net reason.

In any event, for those who may see that same effects, it turns out that
the WM_HSCROLL is apparently generated by Windows when it gets the
WM_SYSCOMMAND + SC_HSCROLL into the DefWindowProc.

What I had done was to intercept ALL WM_SYSCOMMAND messages in order to
prevent the window (which has a caption) from being moved, etc.  By
checking for this message and passing it along, the WM_HSCROLL's started to
show up.



-- 
Barry Press                                 Internet: press@venice.sedd.trw.com