#include "user32.as" #const global WM_HSCROLL 0x114 ;横スクロールバー #const global WM_VSCROLL 0x115 ;縦スクロールバー #define global SB_HORZ 0 ;標準スクロール水平バー #define global SB_VERT 1 ;標準スクロール垂直バー #define global SB_CTL 2 ;スクロールコントロール #define global SB_BOTH 3 ;標準スクロール両方? #const global SB_LINEUP 0 #const global SB_LINELEFT 0 #const global SB_LINEDOWN 1 #const global SB_LINERIGHT 1 #const global SB_PAGEUP 2 #const global SB_PAGELEFT 2 #const global SB_PAGEDOWN 3 #const global SB_PAGERIGHT 3 #const global SB_THUMBPOSITION 4 ;ドラッグの終了を取得 #const global SB_THUMBTRACK 5 ;ドラッグ中ずっと取得 #const global SB_TOP 6 #const global SB_LEFT 6 #const global SB_BOTTOM 7 #const global SB_RIGHT 7 #const global SB_ENDSCROLL 8 #const global SIF_RANGE 0x0001 #const global SIF_PAGE 0x0002 #const global SIF_POS 0x0004 #const global SIF_DISABLENOSCROLL 0x0008 #const global SIF_TRACKPOS 0x0010 #const global SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS) #module "WindowScroolBar" #deffunc scroll_set int flag, int max, int zoom ;---------- --------- ---------- ---------- ---------- ; スクロールバーの設定 ;---------- --------- ---------- ---------- ---------- Sinfo.3 = max-1 Sinfo.4 = ginfo(12+flag)/zoom SetScrollInfo hwnd, flag, varptr(Sinfo), 1 zm = zoom return ;---------- --------- ---------- ---------- ---------- ; スクロールバーの初期化 ;---------- --------- ---------- ---------- ---------- #deffunc scroll_init int id WZ = id ;スクロールバーで画面が動くウインドウID hWS = hwnd ;スクロールバーが付属するウィンドウ dim Sinfo,7 Sinfo.0 = 28 ;UINT cbSize Sinfo.1 = SIF_POS | SIF_RANGE | SIF_PAGE ;UINT fMask ;Sinfo.2 = 0 ;int nMin ;Sinfo.3 = 100 ;int nMax ;Sinfo.4 = 50 ;UINT nPage (つまみサイズ) ;Sinfo.5 = 0 ;int nPos (つまみ位置) ;Sinfo.6 = 0 ;int nTrackPos SetScrollInfo hwnd, SB_VERT, varptr(Sinfo), 1 ; 取得メッセージ設定 oncmd gosub *OnScroll, WM_HSCROLL oncmd gosub *OnScroll, WM_VSCROLL return ;---------- --------- ---------- ---------- ---------- ; スクロールバーの動作処理 ;---------- --------- ---------- ---------- ---------- *OnScroll if iparam = WM_HSCROLL : h=SB_HORZ : else { if iparam = WM_VSCROLL : h=SB_VERT : else : return } GetScrollInfo hWS, h, varptr(Sinfo) flag = ( wparam & 0xFFFF ) if flag = SB_LINEUP : Sinfo.5-- : goto *@f if flag = SB_LINEDOWN : Sinfo.5++ : goto *@f if flag = SB_PAGEUP : Sinfo.5-= Sinfo.4 : goto *@f if flag = SB_PAGEDOWN : Sinfo.5+= Sinfo.4 : goto *@f if flag = SB_THUMBTRACK : Sinfo.5 = ( wparam >> 16 ) & 0xFFFF : goto *@f if flag = SB_TOP : Sinfo.5 = Sinfo.2 : goto *@f if flag = SB_BOTTOM : Sinfo.5 = Sinfo.3 : goto *@f return *@ SetScrollInfo hWS, h, varptr(Sinfo), 1 goto *@f ;---------- --------- ---------- ---------- ---------- ; 画像を表示させる ;---------- --------- ---------- ---------- ---------- #deffunc scroll_image *@ GetScrollInfo hWS, SB_HORZ, varptr(Sinfo) x=Sinfo.5 : w=Sinfo.4 : if Sinfo.3 >= x+w : w++ GetScrollInfo hWS, SB_VERT, varptr(Sinfo) y=Sinfo.5 : h=Sinfo.4 : if Sinfo.3 >= y+h : h++ ;Sinfo.2 = 0 ;int nMin ;Sinfo.3 = 100 ;int nMax ;Sinfo.4 = 50 ;UINT nPage (つまみサイズ) ;Sinfo.5 = 0 ;int nPos (つまみ位置) redraw 0 syscolor 17 : boxf 0,0,ginfo_winx,ginfo_winy gzoom w*zm, h*zm, WZ, x,y, w, h redraw 1 return ;---------- --------- ---------- ---------- ---------- #global ID_def=3 buffer ID_def,32,32 color 255,128, 0 : boxf 0,0,31,31 color 255,255,255 : boxf 1,1,30,30 imgx=ginfo_winx imgy=ginfo_winy zoom=10 screen 0,300,300 ;スクロールバーの設定 scroll_init ID_def scroll_set SB_HORZ, imgx, zoom scroll_set SB_VERT, imgy, zoom scroll_set SB_HORZ, imgx, zoom scroll_set SB_VERT, imgy, zoom scroll_image stop