;---------- ---------- ---------- ---------- ---------- ; 作成者のURL ---> http://www.setsuki.com/ ;---------- ---------- ---------- ---------- ---------- #include "user32.as" #include "Comctl32.as" ; レバーコントロールとペイジャーの使用宣言? ic = 8, 0x00001400 : InitCommonControlsEx varptr(ic) ;---------- ---------- ---------- ---------- ---------- ; レバーコントロールの作成 ;---------- ---------- ---------- ---------- ---------- ; rebar p1 ; p1 = スタイル ;---------- ---------- ---------- ---------- ---------- ; レバーコントロールに表示オブジェクトを入れ込む ;---------- ---------- ---------- ---------- ---------- ; inrebar p1,p2,p3,p4 ; p1 = オブジェクトID ; p2 = 表示文字 ; p3 = 横幅(表示位置?) ; p4 = ペイジャーのON/OFF ;---------- ---------- ---------- ---------- ---------- ; 操作するレバーコントロールを変更 ;---------- ---------- ---------- ---------- ---------- ; rebarsel p1 ; p1 = オブジェクトID ;---------- ---------- ---------- ---------- ---------- #define global WM_SIZE 0x0005 ;ウィンドウサイズ変更 #define global WM_NOTIFY 0x004E ;コモンコントロールからの通知 #module ;---------- ---------- ---------- ---------- ---------- ; [ レバーコントロール使用マクロ ] ; CreateWindowEX の dwStyle に指定する値 #define RBS_BANDBORDERS 0x00000400 #define CCS_NODIVIDER 0x00000040 #define CCS_VERT 0x00000080 ;ver4.70〜 縦表示 ; sendmsg で使用 #define RB_SETBARINFO 0x0404 #define RB_INSERTBAND 0x0401 ; fMask に指定する値 #define RBBIM_STYLE 0x00000001 #define RBBIM_COLORS 0x00000002 #define RBBIM_TEXT 0x00000004 #define RBBIM_IMAGE 0x00000008 #define RBBIM_CHILD 0x00000010 #define RBBIM_CHILDSIZE 0x00000020 #define RBBIM_SIZE 0x00000040 #define RBBIM_BACKGROUND 0x00000080 #define RBBIM_IDEALSIZE 0x00000200 ; fStyle に指定する値 #define RBBS_BREAK 0x00000001 ;改行 #define RBBS_FIXEDSIZE 0x00000002 ;バンドのサイズを固定 #define RBBS_CHILDEDGE 0x00000004 ;子ウィンドウの周りに隙間を入れる #define RBBS_HIDDEN 0x00000008 ;非表示 #define RBBS_VARIABLEHEIGHT 0x00000040 ;子ウィンドウに高さを合わせる #define RBBS_GRIPPERALWAYS 0x00000080 ;グリッパーを常に表示 #define RBBS_NOGRIPPER 0x00000100 ;グリッパーを表示しない ; WM_NOTIFY で使用可能 #define RBN_HEIGHTCHANGE -831 ;---------- ---------- ---------- ---------- ---------- ; [ ページャー使用のマクロ ] ; CreateWindowEX の dwStyle に指定する値 #define PGS_VERT 0x00000000 #define PGS_HORZ 0x00000001 #define PGS_AUTOSCROLL 0x00000002 #define PGS_DRAGNDROP 0x00000004 ; sendmsg や WM_NOTIFY で使用する値 #define PGM_FIRST 0x1400 #const PGM_SETCHILD (PGM_FIRST+1) #const PGM_SETBKCOLOR (PGM_FIRST+4) #const PGM_SETPOS (PGM_FIRST+8) #const PGM_GETPOS (PGM_FIRST+9) #const PGM_SETBUTTONSIZE (PGM_FIRST+10) #const PGM_GETBUTTONSIZE (PGM_FIRST+11) #define PGN_FIRST -900 #const PGN_SCROLL (PGN_FIRST-1) #const PGN_CALCSIZE (PGN_FIRST-2) #define PGF_CALCWIDTH 1 #define PGF_CALCHEIGHT 2 ; ページャーの背景を設定 #define global Pager_SetBkColor(%1,%2) sendmsg %1,PGM_SETBKCOLOR,0,%2 ;(例:背景を赤にする) Pager_SetBkColor hPager, 0x0000FF ;---------- ---------- ---------- ---------- ---------- #define cbSize 0 #define fMask 1 #define fStyle 2 #define clrFore 3 #define clrBack 4 #define lpText 5 #define cch 6 #define iImage 7 #define hwndChild 8 #define cxMinChild 9 #define cyMinChild 10 #define cx 11 #define hbmBack 12 #define wID 13 #define pmax 10 ;ペイジャー設置数 ;---------- ---------- ---------- ---------- ---------- ; レバーコントロールの作成 ;---------- ---------- ---------- ---------- ---------- #deffunc rebar int style winobj "ReBarWindow32", "", 0x80, 0x56000040 | style hRebar = objinfo(stat,2) ; イメージリストを使用する場合のみ必要 rbi=12,0,0 sendmsg hRebar, RB_SETBARINFO, 0, varptr(rbi) return ;---------- ---------- ---------- ---------- ---------- ; 選択中のレバーコントロールの変更 ;---------- ---------- ---------- ---------- ---------- #deffunc rebarsel int obj hRebar = objinfo(obj,2) return ;---------- ---------- ---------- ---------- ---------- ; レバーコントロールにアイテム追加 ;---------- ---------- ---------- ---------- ---------- #deffunc inrebar int obj, str com, int w, int flag if( hRebar == 0 ): return sdim String, strlen(com)+1 : String = com ; ペイジャーの設置 if( flag != 0 )&&( max < pmax ){ ; ペイジャーの作成 winobj "SysPager","", 0, 0x56000001 hPager.max = objinfo(stat,2) ; 指定オブジェクトの親ウィンドウを変更 setWindowLong objinfo(obj,2), -8, hPager.max ; ペイジャーに指定オブジェクトを設定 sendmsg hPager.max, PGM_SETCHILD, 0, objinfo(obj,2) hchild = hPager.max : max++ oncmd gosub *OnWM_NOTIFY, WM_NOTIFY } else { hchild = objinfo(obj,2) } ; 親ウィンドウを変更 setWindowLong hchild, -8, hRebar ; REBARINFO構造体 dim rbBand, 20 rbBand.cbSize = 60 rbBand.fMask = RBBIM_TEXT | RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE rbBand.fStyle = RBBS_CHILDEDGE rbBand.cxMinChild = 0 rbBand.cyMinChild = 25 rbBand.lpText = varptr(String) rbBand.hwndChild = hchild rbBand.cx = w : if( w == 0 ): rbBand.cx = 64 ;バンドの長さ ; レバーコントロールに追加 sendmsg hRebar, RB_INSERTBAND, -1, varptr(rbBand) return ;---------- ---------- ---------- ---------- ---------- *OnWM_NOTIFY dupptr data, lparam, 12 repeat max if( data.0 == hPager.cnt ){ ; ページャーのサイズ変更処理 if( data.2 == PGN_CALCSIZE ){ dupptr data, lparam, 24 if( data.3 == PGF_CALCWIDTH ){ data.4 = 200 } } ;if( data.2 == PGN_SCROLL ){ ;} break } loop /*if( data.0 == hRebar ){ ; バーの高さが変化した時の処理 if( data.2 == RBN_HEIGHTCHANGE ){ InvalidateRect hWnd, 0, 1 UpdateWindow hRebar } }*/ return ;---------- ---------- ---------- ---------- ---------- #global gsel 0,-1 screen 2,640,480,,,,400 : title "レバーコントロールのテスト" chk = 2 : combox chk,200,"青\n赤\n緑\n黄色" name = "" : input name button "終了", *OnFinish ; レバーコントロールの作成 rebar 0x00000400 ; レバーコントロールにアイテム追加 inrebar 0, "コンボボックス" , 200 inrebar 1, "インプットボックス", 230, 1 inrebar 2, "ボタン" , 100, 1 oncmd gosub *OnSIZE, WM_SIZE onexit gosub *OnFinish stop *OnSIZE ; レバーコントロールにも通知 sendmsg objinfo(3,2), WM_SIZE, wparam, lparam return *OnFinish end