More ... | メニューバーを表示するメニューを表示する
HSP3.0対応版。 スクリプト; メニューバー to Hot Soup Processor 3.0 β1 compatible
; thanks ちょくと さん
; http://chokuto.ifdef.jp/urawaza/menu1.html
; http://chokuto.ifdef.jp/urawaza/menu2.html
; DLLのロードと関数の宣言・初期化など
#uselib "user32.dll"
#func global CreateMenu "CreateMenu"
#func global CreatePopupMenu "CreatePopupMenu"
#func global AppendMenu "AppendMenuA" int, int, int, str
#func global SetMenu "SetMenu" int, int
#func global DrawMenuBar "DrawMenuBar" int
#func global PostMessage "PostMessageA" int, int, sptr, sptr
; ウィンドウメッセージを定義
#const global WM_CLOSE 0x0010
#const global WM_COMMAND 0x0111
; メニューアイテムIDを定義
#const global NULL 0 ; NULL
#const global CMD_OPEN 1 ; [開く]アイテムのID
#const global CMD_SAVE 2 ; [保存]アイテムのID
#const global CMD_QUIT 3 ; [終了]アイテムのID
#const global CMD_MESS 4 ; [表示]アイテムのID
; メッセージ割り込み
oncmd gosub *OnCommand, WM_COMMAND
onexit gosub *OnExitMess
; ポップアップメニューの作成
; [ファイル]メニュー
CreatePopupMenu
hfilemenu = stat
AppendMenu hfilemenu, 0, CMD_OPEN, "開く(&O)" ; 開く
AppendMenu hfilemenu, 0, CMD_SAVE, "保存(&S)" ; 保存
AppendMenu hfilemenu, 0x800, NULL, "" ; セパレータ
AppendMenu hfilemenu, 0, CMD_QUIT, "終了(&Q)" ; 終了
; [ヘルプ]メニュー
CreatePopupMenu
hhelpmenu = stat
AppendMenu hhelpmenu, 0, CMD_MESS, "表示(&M)" ; 表示
; メニューバーの作成
CreateMenu
hmenu = stat
AppendMenu hmenu, 0x10, hfilemenu, "ファイル(&F)" ; ファイル
AppendMenu hmenu, 0x10, hhelpmenu, "ヘルプ(&H)" ; ヘルプ
AppendMenu hmenu, 0, CMD_QUIT, "終了(&Q)" ; 終了
SetMenu hwnd, hmenu ; メニューをウィンドウに割り当てる
DrawMenuBar hwnd ; メニューを再描画
stop
; メッセージの処理
*OnCommand
switch (wparam & 0xFFFF)
case CMD_OPEN ; 開く
dialog "*", 16
if stat = 1 {
dialog refstr + "を開きました", 0, "テスト"
}
swbreak
case CMD_SAVE ; 保存
dialog "*", 17
if stat = 1 {
dialog refstr + "を保存しました", 0, "テスト"
}
swbreak
case CMD_QUIT ; 終了
; ( Send だと終了できないので注意 )
PostMessage hwnd, WM_CLOSE, 0, 0
swbreak
case CMD_MESS ; 表示
dialog "メニュー作成のテストです", 0, "メッセージ表示"
swbreak
default
swbreak
swend
return
*OnExitMess
dialog "終了しますか?", 2, "確認"
if stat = 6 {
end
}
return
|