/*------------------------------------- 使用例) #include "menubar.as" #enum CMD_NEW = 1 #enum CMD_OPEN #enum CMD_QUIT ; メニューバーの作成 menumake hmenu menupop hmenu, hfilemenu, "ファイル(&F)" menuadd hfilemenu, 0, CMD_NEW , "新規作成(&N)\tCtrl+N" menuadd hfilemenu, 0, CMD_OPEN, "開く(&O)\tCtrl+O" menuadd hfilemenu, 0x800, NULL, "" menuadd hfilemenu, 0, CMD_QUIT, "終了(&X)" ; メニューを描画する menudraw hmenu ; メッセージ割り込み実行指定 onmenu gosub *OnCommand stop *OnCommand cmd = ( wparam & 0xFFFF ) if( cmd == CMD_NEW ): dialog "新規作成" if( cmd == CMD_OPEN ): dialog "",16,"" if( cmd == CMD_QUIT ): dialog "終了しまっせ" : end return -------------------------------------*/ #ifdef __hsp30__ #ifndef __USER32__ #define global __USER32__ #uselib "USER32.DLL" #func global CreateMenu "CreateMenu" #func global CreatePopupMenu "CreatePopupMenu" #func global DeleteMenu "DeleteMenu" sptr,sptr,sptr #func global DestroyMenu "DestroyMenu" sptr #func global DrawMenuBar "DrawMenuBar" sptr #func global SetMenu "SetMenu" sptr,sptr #func global SetMenuItemInfo "SetMenuItemInfoA" sptr,sptr,sptr,sptr #func global InsertMenu "InsertMenuA" sptr,sptr,sptr,sptr,sptr #endif #endif #ifndef WM_COMMAND #define global WM_COMMAND 0x0111 #endif #ifndef NULL #define global NULL 0 #endif #define global MF_BYCOMMAND 0x00000000 ;メニュー項目指定 #define global MF_BYPOSITION 0x00000400 ;ポジション指定 #define global MF_ENABLED 0x00000000 ;有効にする #define global MF_GRAYED 0x00000001 ;無効にし、淡色表示 #define global MF_DISABLED 0x00000002 ;無効にする #define global MF_STRING 0x00000000 ;メニュー項目は文字列 #define global MF_BITMAP 0x00000004 ;ビットマップ使用 #define global MF_OWNERDRAW 0x00000100 ;メニュー項目はオーナードロー #define global MF_SEPARATOR 0x00000800 ;区切り線 #define global MF_UNCHECKED 0x00000000 ;チェックマークを表示しない #define global MF_CHECKED 0x00000008 ;チェックマーク #define global MF_POPUP 0x00000010 ;メニュー項目はサブメニュー #define global MF_MENUBARBREAK 0x00000020 ;メニューバーを指定の位置で改行する #define global MF_MENUBREAK 0x00000040 ;メニューバーを改行し、サブメニューは新しい列を作る ;-------------------------------------- ; メニューバーコマンドの設定 ;-------------------------------------- #define onmenu(%1) oncmd %1, WM_COMMAND ;-------------------------------------- ; アイテムを削除 ;-------------------------------------- #define menudel(%1,%2,%3=MF_BYPOSITION) DeleteMenu %1,%2,%3 ;-------------------------------------- ; メニューバーの削除 ;-------------------------------------- #define menufree(%1) DestroyMenu %1 #module memu ;-------------------------------------- ; メニューバーを作成する ;-------------------------------------- #deffunc menumake var handle CreateMenu : handle=stat return ;-------------------------------------- ; メニューバーを描画する ;-------------------------------------- #deffunc menudraw int handle SetMenu hwnd, handle : DrawMenuBar hwnd return ;-------------------------------------- ; ポップアップメニューを作成 ;-------------------------------------- #deffunc menupop int handle, var id, str mstr CreatePopupMenu : id=stat if( strlen(mstr) > 0 ){ InsertMenu handle, -1, MF_BYPOSITION | MF_POPUP, id, mstr } return ;-------------------------------------- ; アイテムを追加する ;-------------------------------------- #deffunc menuadd int handle, int flag, int id, str mstr, int upos if( upos < 1 ) : prm = -1 : else : prm = upos InsertMenu handle, prm, MF_BYPOSITION | flag, id, mstr return ;-------------------------------------- ; ポップアップメニューの変更 ;-------------------------------------- #deffunc menuprm int handle, int id, str mstr dim prm,12 : prm = 48, $11 : menustr=mstr prm.9 = varptr(menustr), strlen(menustr) SetMenuItemInfo handle,id,0,varptr(prm) return ;-------------------------------------- ; アイテムにチェックをつける ;-------------------------------------- #deffunc menuchk int handle, int id, int flag dim prm,12 : prm = 44, 1 if flag > 0 : prm.3 = MF_CHECKED SetMenuItemInfo handle,id,0,varptr(prm) return ;-------------------------------------- ; アイテムを灰色にする ;-------------------------------------- #deffunc menugray int handle, int id, int flag dim prm,12 : prm = 44, 1 if flag = 0 : prm.3 = MF_GRAYED SetMenuItemInfo handle,id,0,varptr(prm) return ;-------------------------------------- #global