Hi all,
How can I in code control the scrollbar control with an timer component?
Kind regards
Stephane
You didn't say exactly how you were wanting to control the scroll and on what so here's a modified version of a modified program I played with some time ago.
autodefine "Off"
CONST SB_CTL = 2
CONST SB_HORZ = 0
CONST SB_VERT = 1
CONST SIF_DISABLENOSCROLL = 0x8
CONST SIF_PAGE = 0x2
CONST SIF_POS = 0x4
CONST SIF_RANGE = 0x1
CONST SIF_TRACKPOS = 0x10
CONST SIF_ALL = (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
TYPE SCROLLINFO
UINT cbSize
UINT fMask
int nMin
int nMax
UINT nPage
int nPos
int nTrackPos
ENDTYPE
DECLARE IMPORT,SetScrollInfo(hwnd as UINT,id as INT,sinfo as SCROLLINFO,bRedraw as INT),INT
DECLARE IMPORT,GetScrollInfo(hwnd as UINT,id as INT,sinfo as SCROLLINFO),INT
def PageSizeH,PageSizeV:int
def w:window
def w1:window
def cwinheight:int
def cwinwidth:int
def cx,cy,ax,ay:int
openwindow w,0,0,500,500,@vscroll|@hscroll|@maxbox|@minbox|@size,0,"hello",&whnd
openwindow w1,0,0,700,700,@size,w,"",&subwindow
SETWINDOWCOLOR w1, RGB(255,0,0)
control w1,@button,"Test",10,600,70,22,0,10
cwinheight=1000
cwinwidth=1000
AdjustScrollV()
AdjustScrollH()
move w1,0,0
print w1,"Top"
move w1,0,670
print w1,"Bottom"
move w1,1000,1000
print w1,"."
STARTTIMER w, 50
waituntil w.hwnd=0
end
'--------------------------------------------------------------------------
sub whnd(),int
def Moved,xy:int
select @class
case @idclosewindow
STOPTIMER w
closewindow w
case @idsize
if w.hwnd
AdjustScrollV()
AdjustScrollH()
endif
case @idvscroll
case& @idhscroll
if @class = @idvscroll then xy=-2 else xy=-1
Moved=True
select @code
case @sbthumbtrack
Setscrollpos(w,xy,@qual)
case @sblinedown
Setscrollpos(w,xy,getscrollpos(w,xy)+1)
case @sblineup
Setscrollpos(w,xy,getscrollpos(w,xy)-1)
case @sbpagedown
Setscrollpos(w,xy,getscrollpos(w,xy)+PageSizeV)
case @sbpageup
Setscrollpos(w,xy,getscrollpos(w,xy)-PageSizeV)
default
Moved=False
endselect
if Moved then Reshow()
case @idpaint
reshow()
case @IDTIMER
Setscrollpos(w,-2,getscrollpos(w,-2)+5) '+5
reshow()
endselect
return 0
endsub
sub AdjustScrollV()
def si:SCROLLINFO
def cx,cy,ax,ay:int
getclientsize w,ax,ay,cx,cy
si.cbSize=len(si)
si.nMin=0
si.nMax=cwinheight-1
si.nPage=cy
si.fMask=SIF_RANGE|SIF_PAGE
SetScrollInfo(w.hwnd,SB_VERT,si,1)
PageSizeV=cy
return
endsub
sub AdjustScrollH()
def si:SCROLLINFO
def cx,cy,ax,ay:int
getclientsize w,ax,ay,cx,cy
si.cbSize=len(si)
si.nMin=0
si.nMax=cwinwidth-1
si.nPage=cx
si.fMask=SIF_RANGE|SIF_PAGE
SetScrollInfo(w.hwnd,SB_HORZ,si,1)
PageSizeH=cx
return
endsub
'------------------------------------------------------------------------
sub subwindow(),int
select @class
case @idclosewindow
closewindow w1
case @idsize
AdjustScrollV()
AdjustScrollH()
getsize w1,ax,ay,cx,cy
SETCAPTION w, str$(ax)+str$(ay)+str$(cx)+str$(cy)
endselect
return 0
endsub
'------------------------------------------------------------------------
sub reshow()
def ax,ay,cx,cy:int
def tl,t2:int
tl=getscrollpos(w,-2)
t2=getscrollpos(w,-1)
getsize w1,ax,ay,cx,cy
setsize w1,-t2,-tl,cx,cy
return
endsub