1. RE: (Newbie) Using built-in scrollbars - ta Dan!
- Posted by pg_russell at lineone.net Nov 04, 2001
- 342 views
Dan, Thanks very much for your amended code - it got me thinking and I have now figured out how to alter the scroll ranges as well. I delved into some win32 documentation and it turned out that you should be able to get/set built-in scrollbar attributes with the get/setScrollInfo functions. Looking in win32lib these functions exist but they have not been quite correctly implemented for built-in scrollbars. I extracted & fixed the relevant code and I attach an amended code sample below which shows the built-in scrollbar ranges being altered programmatically. Do you happen to know who I should send win32lib fix requests to these days? Many thanks to you and everybody else who replied to my original post Regards, Phil -- scroll.exw -- Test built-in scrollbars -- (displays scrollbar position in window) -- Phil Russell Nov 2001 ---- with slight modification by Dan Moyer ---- and further by Phil after inspiration provided above... without warning include win32lib.ew -- Create window with built-in scrollbars constant ScrollWin = create( Window, "ScrollTest", 0, Default, Default, 200, 200, WS_SCROLLBARS ) -- Modified from win32lib.setScrollRange procedure setBuiltInScrollRange( integer window_id, integer scrollbar, integer min, integer max ) -- set the allowable range for a scroll bar atom sif object VOID -- ***duplicated from win32lib -- store value ***no access to win32lib private sequence --window_range[ id ] = { min, max } -- Allocate structure sif = acquire_mem(0, SIZEOF_SCROLLINFO ) -- store values store( sif, sifSize, SIZEOF_SCROLLINFO ) store( sif, sifMask, SIF_RANGE ) store( sif, sifMin, min ) store( sif, sifMax, max ) -- check for valid scrollbar option -- SB_VERT = vertical scrollbar -- SB_HORZ = horizontal scrollbar if scrollbar = SB_VERT or scrollbar = SB_HORZ then VOID = w32Func( xSetScrollInfo, { getHandle( window_id ), -- handle scrollbar, -- scroll bar to change sif, -- pointer to structure 0 } ) -- redraw flag end if -- Free structure release_mem( sif ) end procedure -- Process scroll event (as amended by Dan Moyer and further by me) procedure onScroll_ScrollWin( integer pos) -- show scrollbar positions setPenPosition( ScrollWin, 1, 10 ) -- ADD THIS wPuts(ScrollWin, "Horizontal: " & sprint(getHScrollPos( ScrollWin ))) -- AND THIS setPenPosition( ScrollWin, 1, 30 )-- AND THIS wPuts(ScrollWin, "Vertical: " & sprint(getVScrollPos( ScrollWin ))) --AND THIS end procedure procedure onOpen_ScrollWin () -- *** Fool win32lib into not clipping the scrollbars setScrollRange(ScrollWin, 0, 999) -- *** Alter the scroll ranges setBuiltInScrollRange( ScrollWin, SB_VERT, 0, 500 ) setBuiltInScrollRange( ScrollWin, SB_HORZ, 0, 20 ) end procedure -- Trap scroll event onScroll[ScrollWin] = routine_id("onScroll_ScrollWin") -- Initialisation onOpen[ScrollWin] = routine_id("onOpen_ScrollWin") -- Hand control over to Windows WinMain( ScrollWin, Normal )
2. RE: (Newbie) Using built-in scrollbars - ta Dan!
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Nov 04, 2001
- 350 views
Couple small additions/corrections: -- scroll.exw -- Test built-in scrollbars -- (displays scrollbar position in window) -- Phil Russell Nov 2001 ---- with slight modification by Dan Moyer ---- and further by Phil after inspiration provided above... without warning include win32lib.ew include graphics.e -- Create window with built-in scrollbars constant ScrollWin = create( Window, "ScrollTest", 0, Default, Default, 200, 200, WS_SCROLLBARS ) -- Modified from win32lib.setScrollRange procedure setBuiltInScrollRange( integer window_id, integer scrollbar, integer min, integer max ) -- set the allowable range for a scroll bar atom sif object VOID -- ***duplicated from win32lib -- store value ***no access to win32lib private sequence --window_range[ id ] = { min, max } -- Allocate structure sif = acquire_mem(0, SIZEOF_SCROLLINFO ) -- store values store( sif, sifSize, SIZEOF_SCROLLINFO ) store( sif, sifMask, SIF_RANGE ) store( sif, sifMin, min ) store( sif, sifMax, max ) -- check for valid scrollbar option -- SB_VERT = vertical scrollbar -- SB_HORZ = horizontal scrollbar if scrollbar = SB_VERT or scrollbar = SB_HORZ then VOID = w32Func( xSetScrollInfo, { getHandle( window_id ), -- handle scrollbar, -- scroll bar to change sif, -- pointer to structure 0 } ) -- redraw flag end if -- Free structure release_mem( sif ) end procedure -- Process scroll event (as amended by Dan Moyer and further by me) procedure onScroll_ScrollWin( integer pos) --Clear the old text before we write to the window. repaintWindow(ScrollWin) -- show scrollbar positions --Not setPenPosition, just setPenPos :) setPenPos( ScrollWin, 1, 10 ) -- ADD THIS wPuts(ScrollWin, "Horizontal: " & sprint(getHScrollPos( ScrollWin ))) --AND THIS setPenPos( ScrollWin, 1, 30 )-- AND THIS wPuts(ScrollWin, "Vertical: " & sprint(getVScrollPos( ScrollWin ))) --AND THIS end procedure procedure onOpen_ScrollWin () -- *** Fool win32lib into not clipping the scrollbars setScrollRange(ScrollWin, 0, 999) -- *** Alter the scroll ranges setBuiltInScrollRange( ScrollWin, SB_VERT, 0, 500 ) setBuiltInScrollRange( ScrollWin, SB_HORZ, 0, 20 ) end procedure -- Trap scroll event onScroll[ScrollWin] = routine_id("onScroll_ScrollWin") -- Initialisation onOpen[ScrollWin] = routine_id("onOpen_ScrollWin") -- Hand control over to Windows WinMain( ScrollWin, Normal )
3. RE: (Newbie) Using built-in scrollbars - ta Dan!
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Nov 04, 2001
- 349 views
oops, graphics.e doesn't need to be included. When I tried to run the code, and saw the setPenPosition error, my first impulse was obviously that the include was forgotten. Then I looked it up and found the correct command (RTFM, Cassidy). Sorry. -=Cassidy Napoli=-
4. RE: (Newbie) Using built-in scrollbars - ta Dan!
- Posted by pg_russell at lineone.net Nov 05, 2001
- 334 views
Cassidy, Thanks for this. It took me quite a while to work out why setPenPosition worked for me but not for you. Eventually I found it in compat01.ew which apparently contains deprecated win32lib functions. Evidently it is included in my version of win32lib but not yours. As you rightly point out, setPenPos is the correct function to use. Regards Phil Cassidy Napoli wrote: > oops, graphics.e doesn't need to be included. When I tried to run the > code, and saw the setPenPosition error, my first impulse was obviously > that the include was forgotten. Then I looked it up and found the > correct command (RTFM, Cassidy). Sorry. > > -=Cassidy Napoli=- > >