RE: (Newbie) Using built-in scrollbars - ta Dan!
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Nov 04, 2001
- 349 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 )