More ... | HSP3標準ライブラリ:statusbar.as
ステータスバー作成 statusbar.as/* * statusbar.as * * ステータスバー作成モジュール */ #ifndef STATUSBAR_HSP_INCLUDED #define global STATUSBAR_HSP_INCLUDED #module Statusbar #uselib "comctl32" #func InitCommonControls "InitCommonControls" #func InitCommonControlsEx "InitCommonControlsEx" int #uselib "user32" #func GetWindowRect "GetWindowRect" int, int #const ICC_BAR_CLASSES 0x00000004 #const WS_VISIBLE 0x10000000 #const WS_CHILD 0x40000000 #const SB_SETPARTS 0x00000404 #const SB_SETTEXT 0x00000401 #const SB_SETICON 0x0000040F #const SB_SIMPLE 0x00000409 #const WM_SIZE 0x00000005 /* * create_statusbar * * ステータスバーを作成し、オブジェクトIDをstatに返します。 */ #deffunc create_statusbar if varptr(InitCommonControlsEx) { iccex = 8, ICC_BAR_CLASSES InitCommonControlsEx varptr(iccex) } else { InitCommonControls } winobj "msctls_statusbar32", "", , WS_VISIBLE | WS_CHILD return /* * set_statusparts id, parts * id : ステータスバーのオブジェクトID * parts : パーツの右端座標の配列 * * idのステータスバーに、partsの配列要素数分のパーツを作成します。 * partsの中の値が-1の要素は、ウィンドウの右端までがそのパーツになります。 */ #deffunc set_statusparts int id, array parts sendmsg objinfo_hwnd(id), SB_SETPARTS, length(parts), varptr(parts) return /* * set_statustext id, part, test * id : ステータスバーのオブジェクトID * part : パーツのID * text : 設定するテキスト * * idのステータスバーのpartのパーツに、テキストを設定します。 * partを255にした場合は、シンプルモードのテキストが設定されます。 */ #deffunc set_statustext int id, int part, str text_, int type, local text text = text_ sendmsg objinfo_hwnd(id), SB_SETTEXT, part | type, varptr(text) return /* * set_statusicon id, part, hicon * id : ステータスバーのオブジェクトID * part : パーツのID * hicon : 設定するアイコンのハンドル * * idのステータスバーのpartのパーツに、アイコンを設定します。 * アイコンのハンドルは、image.asのextract_iconなどで取得してください。 */ #deffunc set_statusicon int id, int part, int hicon sendmsg objinfo_hwnd(id), SB_SETICON, part, hicon return /* * set_statussimple id, flag * id : ステータスバーのオブジェクトID * flag : シンプルモードのフラグ * * idのステータスバーの、シンプルモードの状態を切り替えます。 * flagが1の場合はシンプルモード、0の場合は非シンプルモードになります。 */ #deffunc set_statussimple int id, int flag sendmsg objinfo_hwnd(id), SB_SIMPLE, flag, 0 return /* * get_statusheight id * id : ステータスバーのオブジェクトID * * idのステータスバーの高さをstatに返します。 */ #deffunc get_statusheight int id dim rc, 4 GetWindowRect objinfo_hwnd(id), varptr(rc) return rc(3) - rc(1) /* * move_statusbar id * id : ステータスバーのオブジェクトID * * idのステータスバーの座標を移動します。 * ウィンドウのサイズが変更された時に呼び出してください。 */ #deffunc move_statusbar int id sendmsg objinfo_hwnd(id), WM_SIZE, 0, 0 return #global #endif statusbar_sample.hsp#include "statusbar.as" create_statusbar id_status = stat parts = 480, 560, -1 set_statusparts id_status, parts set_statustext id_status, 0, "PART1" set_statustext id_status, 1, "PART2" set_statustext id_status, 2, "PART3" await 1000 set_statussimple id_status, 1 get_statusheight id_status set_statustext id_status, 255, "ステータスバーの高さは " + stat + " です。" await 1000 set_statussimple id_status, 0 |