I like the TrackBars better than the ScrollBars...
Code: Select all
#define WIN_INCLUDEALL
#Include once "windows.bi"
#Include once "/win/commctrl.bi"
InitCommonControls()
Dim Shared As Long trackpos1=0 , getlast1=1
Dim Shared As Long trackpos2=0 , getlast2=1
Dim shared As MSG msg ' Message variable (stores massages)
Dim shared As HWND hWnd , statics , TrackBar1 , TrackBar2
dim as point ep
hWnd = CreateWindowEx( 0, "#32770", "TrackBar Test", WS_OVERLAPPEDWINDOW Or WS_VISIBLE , 100, 0, 800, 600, 0, 0, 0, 0 )
statics = CreateWindowEx( 0, "STATIC", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD , 10 , 10 , 2300 , 1400 , hWnd, 0, 0, 0 )
TrackBar1 = CreateWindowEx(NULL,TRACKBAR_CLASS, "Trackbar Control", WS_VISIBLE Or WS_CHILD Or TBS_AUTOTICKS Or TBS_ENABLESELRANGE or TBS_HORZ,10,530,740,35,hwnd,0,0,0)
SendMessage(TrackBar1, TBM_SETRANGE,TRUE, MAKELONG(0,25))
TrackBar2 = CreateWindowEx(NULL,TRACKBAR_CLASS, "Trackbar Control", WS_VISIBLE Or WS_CHILD or TBS_AUTOTICKS Or TBS_ENABLESELRANGE or TBS_VERT,750,10,35,520,hwnd,0,0,0)
SendMessage(TrackBar2, TBM_SETRANGE,TRUE, MAKELONG(0,20))
Dim As rect w
getwindowrect(hWnd,@w)
dim as long w_wide = w.right - w.left
dim as long w_high = w.bottom - w.top
dim as long last_w = w_wide
dim as long last_h = w_high
Dim As rect r
getwindowrect(statics,@r)
dim as long s_wide = r.right - r.left
dim as long s_high = r.bottom - r.top
dim as long inc_h = (s_wide \ 25) - (s_wide\200)
dim as long inc_v = (s_high \ 20) - (s_high\200)
ep.x = 0
ep.y = 0
'begin mesage processing
While GetMessage( @msg, 0, 0, 0 )
dim as WPARAM wparam
dim as LPARAM lparam
TranslateMessage( @msg )
DispatchMessage( @msg )
Select Case msg.hwnd
Case hWnd
Select Case msg.message
Case 273
PostQuitMessage(0)
'End
case WM_MOUSEMOVE
getwindowrect(hWnd,@w)
w_wide = w.right - w.left
w_high = w.bottom - w.top
if w_wide <> last_w or w_high <> last_h then
SetWindowPos(TrackBar1, 1 , 10 , w_high-60 , w_wide-50, 50, 0)
SetWindowPos(TrackBar2, 1 , w_wide-50 , 10 , 50, w_high-60, 0)
last_w = w_wide
last_h = w_high
ep.x = (getlast1 * inc_h) - inc_h
ep.y = (getlast2 * inc_v) - inc_v
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
end if
End Select
case TrackBar1
Select Case msg.message
Case WM_MOUSEMOVE , WM_LBUTTONDOWN
ShowWindow(TrackBar1, SW_HIDE)
ShowWindow(TrackBar2, SW_HIDE)
trackpos1 = SendMessage(TrackBar1, TBM_GETPOS, 0, 0)
if trackpos1 < getlast1 then
getlast1-=1
ep.x = (getlast1 * inc_h) - inc_h
SendMessage(TrackBar1, TBM_SETPOS,TRUE, getlast1)
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
end if
if trackpos1 > getlast1 then
getlast1+=1
ep.x = (getlast1 * inc_h) - inc_h
SendMessage(TrackBar1, TBM_SETPOS,TRUE, getlast1)
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
end if
ShowWindow(TrackBar1, SW_SHOW)
ShowWindow(TrackBar2, SW_SHOW)
End Select
case TrackBar2
Select Case msg.message
Case WM_MOUSEMOVE , WM_LBUTTONDOWN
ShowWindow(TrackBar1, SW_HIDE)
ShowWindow(TrackBar2, SW_HIDE)
trackpos2 = SendMessage(TrackBar2, TBM_GETPOS, 0, 0)
if trackpos2 < getlast2 then
getlast2-=1
ep.y = (getlast2 * inc_v) - inc_v
SendMessage(TrackBar2, TBM_SETPOS,TRUE, getlast2)
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
end if
if trackpos2 > getlast2 then
getlast2+=1
ep.y = (getlast2 * inc_v) - inc_v
SendMessage(TrackBar2, TBM_SETPOS,TRUE, getlast2)
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
end if
ShowWindow(TrackBar1, SW_SHOW)
ShowWindow(TrackBar2, SW_SHOW)
End Select
end select
Wend
PostQuitMessage(0)
END