HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2015
0214
甜菜飛鳥モーダルウィンドウとしてウィンドウを表示するモジュール0解決


甜菜飛鳥

リンク

2015/2/14(Sat) 00:28:36|NO.67404

ついでに公開しておきます。モーダルウィンドウとは、よくあるオプション画面などのように
開かれたウィンドウを閉じるまで本画面に制御を移せなくなるやつです。
私個人としてはバージョン表示など以外はモードレスウィンドウのほうがいいと思いますが。

特に著作権は主張しません。

#module mod_modal #uselib "user32.dll" #cfunc GetWindowLong "GetWindowLongA" int, int #func SetWindowLong "SetWindowLongA" int, int, int #cfunc GetProp "GetPropA" int, str #func SetProp "SetPropA" int, str, int #func RemoveProp "RemovePropA" int, str #func SetWindowPos "SetWindowPos" int, int, int, int, int, int, int #func EnableWindow "EnableWindow" int, int #define WS_MAXIMIZEBOX $00010000 #define WS_MINIMIZEBOX $00020000 #define WS_SIZEBOX $00040000 #define WS_SYSMENU $00080000 #define WS_CAPTION $00C00000 #define WS_VISIBLE $10000000 #define GWL_STYLE $FFFFFFF0 #define GWL_HWNDPARENT $FFFFFFF8 #define SWP_NOSIZE $00000001 #define SWP_NOZORDER $00000004 #define SWP_FRAMECHANGED $00000020 #define global open_modal(%1, %2, %3, %4, %5=1) _open_modal %1, %2, %3, %4, %5 // 対象ウィンドウを擬似モーダルウィンドウとして表示する #deffunc _open_modal int owner_id, int modal_id, int x, int y, int change_style sel_id = ginfo_sel gsel owner_id : owner_hwnd = hwnd gsel modal_id style = GetWindowLong(hwnd, GWL_STYLE) hwnd_parent = GetWindowLong(hwnd, GWL_HWNDPARENT) SetProp hwnd, "is_hsp_modal", 1 SetProp hwnd, "owner_id", owner_id SetProp hwnd, "origin_hwnd_parent", hwnd_parent SetProp hwnd, "origin_style", style SetWindowLong hwnd, GWL_HWNDPARENT, owner_hwnd if change_style ! 0 : SetWindowLong hwnd, GWL_STYLE, WS_CAPTION | WS_SYSMENU SetWindowPos hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED EnableWindow owner_hwnd, 0 gsel modal_id, 1 gsel sel_id return // モーダルウィンドウとして表示したウィンドウを片付ける(異なるウィンドウは非表示にするだけ) #deffunc close_modal int modal_id sel_id = ginfo_sel gsel modal_id, -1 if GetProp(hwnd, "is_hsp_modal") = 0 : gsel sel_id : return 0 owner_id = GetProp(hwnd, "owner_id") hwnd_parent = GetProp(hwnd, "origin_hwnd_parent") style = GetProp(hwnd, "origin_style") SetWindowLong hwnd, GWL_STYLE, style SetWindowLong hwnd, GWL_HWNDPARENT, hwnd_parent RemoveProp hwnd, "is_hsp_modal" RemoveProp hwnd, "owner_id" RemoveProp hwnd, "origin_hwnd_parent" RemoveProp hwnd, "origin_style" gsel owner_id, 1 EnableWindow hwnd, 1 gsel sel_id return 1 // 対象のウィンドウがモーダルウィンドウかどうかチェックする #defcfunc is_modal int modal_id sel_id = ginfo_sel gsel modal_id return (GetProp(hwnd, "is_hsp_modal") ! 0) gsel sel_id #global #if 1 /* example */ screen 0 : title "A" screen 1, 300, 200, screen_fixedsize | screen_hide : title "B" : button gosub "OK", *close_button screen 2, 300, 200, screen_fixedsize | screen_hide : title "C" : button gosub "OK", *close_button open_modal 0, 1, 200, 200, 0 // AをオーナーにBをモーダル化(第5引数が偽ならばスタイルを変更しない) open_modal 1, 2, 400, 200 // さらにBをオーナーにCをモーダル化 onexit *on_exit stop *close_button close_modal ginfo_act return *on_exit id = wparam switch id case 0 end default close_modal id swend stop #endif



この記事に返信する


ONION software Copyright 1997-2023(c) All rights reserved.