1. RE: Scrolling Toolbar??
- Posted by Phil Russell <pg_russell at lineone.net> Oct 06, 2002
- 401 views
Hi Ron, I think that the best solution would be to have the scrollable content in your app contained within a child window of the main window i.e. you have: Main Window contains: -Toolbar window -Scrollable content window Then you set the content window to have scrollbars and use ScrollWindow to scroll its contents. This means that the scrollbar will only appear alongside the content and will not cut across the toolbar. This would give you the equivalent of the third option that you mention. The only problem would be coping with changes in the size of the parent window. HTH, Phil Russell Ron Tarrant wrote: > Hi All, > > The title says it. I had scrolling working relatively okay, then I > added a toolbar. When the window contents scroll, the toolbar goes > along for the ride... right out of sight. > > I tried various things like added the scrollbars after the toolbar > was in place using addStyle(). I tried switching to getClientRect() > for window metrics (as opposed to getRect() which I was using). I > tried not actually explicitly adding the scrollbars at all which, > to my surprise, still gave me scrollbars when I made a call to > setScrollRanges(). > > After digging through the API docs and win32lib v0.57.9, I think I > see two possibilities for how to fix this, but I need some more > information. > > Possibility One: I could pass a RECT structure to ScrollWindow() > (which I have set up through registerw32Procedure() to call the win32 > function of the same name). I can get the values I need for the RECT > from getClientRect(), but I'm not sure how to set up a RECT "at arms > length" as it were. I'm assuming it's not as simple as passing a > four-value sequence that's pretending to be a RECT structure. > > Possibility Two: I found a routine buried in win32lib called > fDoScroll(), but it isn't declared as global, so therefore isn't > callable without a hack. I'm assuming this is because fDoScroll() > hasn't been fully debugged and integrated into win32lib yet. Or > should I be calling it through some other stub I don't know about? > > I suppose there's a third possibility, too. Is there a way to tell > a window that its vertical scrollbar should have a 'y' offset of a > certain value (so that its origin is _below_ the toolbar)? > > For now, I've removed the toolbar and I can get along without it. But > if someone could shed some light on this for me, I'd really appreciate > it. > > Thanks! (in advance) > > -Ron T. > >
2. RE: Scrolling Toolbar??
- Posted by Ron Tarrant <rtarrant at sympatico.ca> Oct 07, 2002
- 427 views
Phil Russell wrote: > I think that the best solution would be to have the scrollable content > in your app contained within a child window of the main window > i.e. you have: > > Main Window contains: > -Toolbar window > -Scrollable content window > > Then you set the content window to have scrollbars and use ScrollWindow > to scroll its contents. This means that the scrollbar will only appear > alongside the content and will not cut across the toolbar. This would > give you the equivalent of the third option that you mention. The only > problem would be coping with changes in the size of the parent window. Hmmm, yeah I see what you mean. It sounds like a lot more work than I'm willing to do right now. But thanks for the idea. I ran across a tutorial (in C, of course) that mentioned the SBS_BOTTOMALIGN flag which seems to be exactly the kind of thing I'm looking for [along with the output of getClientRect()]. I haven't tried it yet. I'm still scratching my head over whether it's a regular flag or an extended one. Any ideas? -Ron T.
3. RE: Scrolling Toolbar??
- Posted by Phil Russell <pg_russell at lineone.net> Oct 07, 2002
- 441 views
Ron, It isn't that much work - most of it is coping with the fact that win32lib doesn't seem to pass on scroll messages for child windows with scrollbars so you have to duplicate a little bit of code. I have chucked together an example which I *think* does what you want. HTH Phil <start> include Win32Lib.ew without warning constant ScrollWindow = registerw32Procedure( user32, "ScrollWindow", {C_LONG,C_LONG,C_LONG,C_POINTER,C_POINTER} ) constant MainWin = create( Window, "Scroll test", NULL, 0.25, 0.25, 300, 200, 0 ), ToolBar = create( ToolBar, "", MainWin, 0, 0, 0, 34, 0 ) -- Get client area of main window sequence rect rect = getClientRect(MainWin) constant -- Size child window to client area of main window ChildWin = create( Window, "", MainWin, 0, 1, rect[3], rect[4]-35, {WS_CHILD, WS_VISIBLE, WS_VSCROLL} ), Edit1 = create( EditText, "Edit1", ChildWin, 10, 10, 150, 20, 0 ), Edit2 = create( EditText, "Edit2", ChildWin, 10, 110, 150, 20, 0 ), Edit3 = create( EditText, "Edit3", ChildWin, 10, 210, 150, 20, 0 ) -- Variables for holding scroll info integer OldVPos OldVPos = 0 integer MinScroll MinScroll = 1 integer MaxScroll MaxScroll = 100 integer ScrollPage ScrollPage = 10 -- Set Child window scroll range setWindowScrollRange(ChildWin, SB_VERT, MinScroll, MaxScroll, ScrollPage) --*------------------------------------------------------* -- onScrollEvent: Event handler for ChildWin --*------------------------------------------------------* procedure onScrollEvent (atom self, atom event, sequence parms) integer VChange, Pos, scrolltype -- Test for vertical scroll if parms[1] = WM_VSCROLL then scrolltype = lo_word(parms[2]) if find(scrolltype, {SB_THUMBPOSITION, SB_BOTTOM, SB_TOP, SB_LINEDOWN, SB_LINEUP, SB_PAGEDOWN, SB_PAGEUP} ) then Pos = 0 -- Get new scrollbar position depending on scroll event if scrolltype = SB_THUMBPOSITION then Pos = getVScrollPos(self) elsif scrolltype = SB_BOTTOM then Pos = MinScroll elsif scrolltype = SB_TOP then Pos = MaxScroll elsif scrolltype = SB_LINEUP then Pos = OldVPos - 1 elsif scrolltype = SB_LINEDOWN then Pos = OldVPos + 1 elsif scrolltype = SB_PAGEUP then Pos = OldVPos - ScrollPage elsif scrolltype = SB_PAGEDOWN then Pos = OldVPos + ScrollPage end if -- Clip to range if Pos < MinScroll then Pos = MinScroll elsif Pos > MaxScroll then Pos = MaxScroll end if -- Scroll window VChange = OldVPos - Pos w32Proc( ScrollWindow, {getHandle(self),0, VChange, 0, 0} ) setVScrollPos(self, Pos) OldVPos = Pos end if end if end procedure setHandler(ChildWin, w32HEvent, routine_id("onScrollEvent")) WinMain( MainWin, Normal ) <end>
4. RE: Scrolling Toolbar??
- Posted by Phil Russell <pg_russell at lineone.net> Oct 07, 2002
- 413 views
Ron, I added the resize code to the example and fixed a small bug in the scrolling code... Phil <start> include Win32Lib.ew without warning constant ScrollWindow = registerw32Procedure( user32, "ScrollWindow", {C_LONG,C_LONG,C_LONG,C_POINTER,C_POINTER} ) constant MainWin = create( Window, "Scroll test", NULL, 0.25, 0.25, 300, 200, 0 ), ToolBar = create( ToolBar, "", MainWin, 0, 0, 0, 34, 0 ) -- Get client area of main window sequence rect rect = getClientRect(MainWin) constant -- Size child window to client area of main window ChildWin = create( Window, "", MainWin, 0, 1, rect[3], rect[4]-35, {WS_CHILD, WS_VISIBLE, WS_VSCROLL} ), Edit1 = create( EditText, "Edit1", ChildWin, 10, 10, 150, 20, 0 ), Edit2 = create( EditText, "Edit2", ChildWin, 10, 110, 150, 20, 0 ), Edit3 = create( EditText, "Edit3", ChildWin, 10, 210, 150, 20, 0 ) -- Variables for holding scroll info integer OldVPos OldVPos = 0 integer MinScroll MinScroll = 1 integer MaxScroll MaxScroll = 100 integer ScrollPage ScrollPage = 10 -- Set Child window scroll range setWindowScrollRange(ChildWin, SB_VERT, MinScroll, MaxScroll, ScrollPage) --*------------------------------------------------------* -- onScrollEvent: Event handler for ChildWin --*------------------------------------------------------* procedure onScrollEvent (atom self, atom event, sequence parms) integer VChange, Pos, scrolltype -- Test for vertical scroll if parms[1] = WM_VSCROLL then scrolltype = lo_word(parms[2]) if find(scrolltype, {SB_THUMBPOSITION, SB_BOTTOM, SB_TOP, SB_LINEDOWN, SB_LINEUP, SB_PAGEDOWN, SB_PAGEUP} ) then Pos = 0 -- Get new scrollbar position depending on scroll event if scrolltype = SB_THUMBPOSITION then Pos = hi_word(parms[2]) elsif scrolltype = SB_BOTTOM then Pos = MinScroll elsif scrolltype = SB_TOP then Pos = MaxScroll elsif scrolltype = SB_LINEUP then Pos = OldVPos - 1 elsif scrolltype = SB_LINEDOWN then Pos = OldVPos + 1 elsif scrolltype = SB_PAGEUP then Pos = OldVPos - ScrollPage elsif scrolltype = SB_PAGEDOWN then Pos = OldVPos + ScrollPage end if -- Clip to range if Pos < MinScroll then Pos = MinScroll elsif Pos > MaxScroll then Pos = MaxScroll end if -- Scroll window VChange = OldVPos - Pos w32Proc( ScrollWindow, {getHandle(self),0, VChange, 0, 0} ) setVScrollPos(self, Pos) OldVPos = Pos end if end if end procedure setHandler(ChildWin, w32HEvent, routine_id("onScrollEvent")) --*------------------------------------------------------* -- onResize: Event handler for MainWin --*------------------------------------------------------* procedure onResize (atom self, atom event, sequence parms) setRect(ChildWin, 0, 1, parms[2], parms[3]-35, True) end procedure setHandler(MainWin, w32HResize, routine_id("onResize")) --*------------------------------------------------------* WinMain( MainWin, Normal ) <end>
5. RE: Scrolling Toolbar??
- Posted by Ron Tarrant <rtarrant at sympatico.ca> Oct 07, 2002
- 400 views
Thanks, Phil! I'll give this child window thing a whirl. -Ron T. Phil Russell wrote: > Ron, > > I added the resize code to the example and fixed a small bug in the > scrolling code...
6. RE: Scrolling Toolbar??
- Posted by Don Phillips <EuNexus at yahoo.com> Oct 07, 2002
- 395 views
> Hmmm, yeah I see what you mean. It sounds like a lot more work than > I'm willing to do right now. But thanks for the idea. > > I ran across a tutorial (in C, of course) that mentioned the > SBS_BOTTOMALIGN flag which seems to be exactly the kind of thing > I'm looking for [along with the output of getClientRect()]. > I haven't tried it yet. I'm still scratching my head over whether it's > a regular flag or an extended one. Any ideas? > > -Ron T. SBS_BOTTOMALIGN is a normal style flag. If you are considering this style in hopes that scrolling the contents of the window will leave the toolbar alone, I do not think this will help in that regard. I have not played around with full scrolling windows before so this is only an educated guess, but during each scroll event I would send the toolbar a TB_AUTOSIZE message to reposition it back to where it was: Void = sendMessage( Toolbar, TB_AUTOSIZE, 0, 0 ) Don