Re: Scrolling a Window

new topic     » goto parent     » topic index » view thread      » older message » newer message

If anyone else is interested in window scrollbars, I finally stopped
panicking and figured out how to scroll in _both_ directions. This is
built on the code Don Phillips so kindly supplied. My changes are marked
with --** at the ends of the lines. I left out the enhancements Dan
Moyer added (sorry Dan) so that it would be an example of only the
scrolling stuff.

I haven't tried this with win32lib v55, but it works with v57.9:

--------------------------------------------------------------

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, {WS_HSCROLL, WS_VSCROLL, WS_SYSMENU}), --**
Edit1           = create(EditText, "Edit1", MainWin, 10, 10, 150, 20,
0),
Edit2           = create(EditText, "Edit2", MainWin, 10, 110, 150, 20,
0),
Edit3           = create(EditText, "Edit3", MainWin, 10, 210, 150, 20,
0)

integer
OldVPos,
OldHPos --**

OldVPos = 0
OldHPos = 0 --**

procedure ScrollVert(integer Pos)
    integer VChange, HChange --**

    integer hPos, vPos --**
    hPos = getHScrollPos(MainWin) --**
    vPos = getVScrollPos(MainWin) --**

    -- Negative value to scroll up or left
        -- Positive value to scroll down or right
    if vPos = OldVPos then --**
	HChange = OldHPos - Pos --**
	w32Proc(ScrollWindow, {getHandle(MainWin), HChange, 0, 0, 0}) --**
	OldHPos = Pos --**
    else --**
    	VChange = OldVPos - Pos
    	w32Proc(ScrollWindow, {getHandle(MainWin), 0, VChange, 0, 0})
    	OldVPos = Pos
   end if --**

end procedure

onScroll[MainWin] = routine_id("ScrollVert")

WinMain(MainWin, Normal)

-----------------------------------------------------------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu