ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (04/12/91)
Folks: I'm trying to temporarily add horizontal and vertical scroll bars to a window. Will SetWindowLong() do this? If so, how must it be used? I'm trying sumething like the following: SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL); But it doesn't work... Do I also need to call ShowWindow() and/or UpdateWindow()? ADV thanks ANCE Terrell
bcw@rti.rti.org (Bruce Wright) (04/14/91)
In article <1991Apr12.044108.4007@mnemosyne.cs.du.edu>, ebergman@isis.cs.du.edu (Eric Bergman-Terrell) writes: > > I'm trying to temporarily add horizontal and vertical scroll bars to a > window. > > Will SetWindowLong() do this? > > If so, how must it be used? I'm trying sumething like the following: > > SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL); > > But it doesn't work... Do I also need to call ShowWindow() and/or > UpdateWindow()? You probably can add scroll bars dynamically to a a window this way - but you'd certainly have to call ShowWindow again, and probably UpdateWindow as well. But this looks like the hard way to do it - you can just call SetScrollRange (hWnd, SB_VERT, 0, 0, TRUE) and voila - the vertical scroll bar goes away, or SetScrollRange (hWnd, SB_VERT, 0, 100, TRUE) and it comes back again. I'm not sure I see why you need to mess around with SetWindowLong ... Bruce C. Wright
ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (04/14/91)
You're right - no need to mess with SetWindowLong(). Just create the window with scroll bars, then enable/disable them. Terrell BTW thanks everyone for pointing me in the right direction!
bonneau@hyper.hyper.com (Paul Bonneau) (04/15/91)
In article <1991Apr12.044108.4007@mnemosyne.cs.du.edu> ebergman@isis.cs.du.edu (Eric Bergman-Terrell) writes: > >Folks: > >I'm trying to temporarily add horizontal and vertical scroll bars to a >window. > >Will SetWindowLong() do this? > >If so, how must it be used? I'm trying sumething like the following: > >SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL); > The problem is that non-client area scrollbars are actually child windows that are automatically created when the parent window is created. So they will not exist when you change the parent's window style, and there will be nothing to display. What you need to do is create the parent window with the WS_VSCROLL style and then hide the scroll bar with SetScrollRange(hwndParent, SB_VERT, 0, 0, TRUE);. When it is time to show the scrollbar, give it a non-null scroll range and it will appear. cheers - Paul Bonneau.
ssl@hpkslx.mayfield.HP.COM (SSL Guest User) (04/16/91)
Terrell, Try ShowScrollBar(hWnd, SB_HORZ (or SB_VERT), TRUE); The trick is trying to keep track of when the scroll bar is present or not - in order to scroll you client area correctly. Be sure to set your scroll range, and scroll positions as the user doinks with the scroll bar. Best of luck, Thomas