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


HSPTV!掲示板


未解決 解決 停止 削除要請

2013
1124
きのよー最小化してもとに戻す方法2未解決


きのよー

リンク

2013/11/24(Sun) 16:10:37|NO.58438

ウィンドウを無理やり描いて、枠なしウィンドウに無理やりシステムメニューをくっつけました。
そしたら、最小化した後にウィンドウが表示されなくなり、タスクバークリックで最小化ができません。
どのようにしたら使えるようになりますか?
WindowsAPIとか全然知らないので、ご教授お願いします。


title "Wexblorer - 起動中" verinfo="0.01" wsize=800,600,8,25 tsize=wsize(3)+25 wcolor=0,0,0 name="" #include "llmod3/llmod3.hsp" #include "llmod3/obj.hsp" #uselib "user32.dll" #func SetWindowLong "SetWindowLongA" int,int,int #func SetWindowPos "SetWindowPos" int, nullptr, nullptr, nullptr, nullptr, nullptr, int #define global LoadCursor LoadCursorA #func global LoadCursorA "LoadCursorA" sptr,sptr #define global SetClassLong SetClassLongA #func global SetClassLongA "SetClassLongA" sptr,sptr,sptr #func global GetSystemMenu "GetSystemMenu" sptr,sptr #define global InsertMenu InsertMenuA #func global InsertMenuA "InsertMenuA" sptr,sptr,sptr,sptr,sptr #define global GetWindowLong GetWindowLongA #func global GetWindowLongA "GetWindowLongA" sptr,sptr #func global EnableMenuItem "EnableMenuItem" sptr,sptr,sptr #undef mousex #undef mousey #define mousex (mx2-wpos(0)) #define mousey (my2-wpos(1)) /* #undef mousex #undef mousey #define mousex (ginfo(0)-(ginfo(4)+(ginfo(10)-ginfo(12))/2)) #define mousey (ginfo(1)-(ginfo(5)+(ginfo(11)-ginfo(13))-((ginfo(10)-ginfo(12))/2))) */ #module #deffunc defcls array wsize,array wcolor,str name,int loadingfrag color 127,127,127 boxf color wcolor(0),wcolor(1),wcolor(2) boxf 1,1,wsize(0)-2,wsize(1)-2 if loadingfrag=1{ if wcolor(0)+wcolor(1)+wcolor(2)<=381:color wcolor(0),(wcolor(1)+255)/2,wcolor(2):else:color 0.8*wcolor(0),wcolor(1),0.8*wcolor(2) boxf 1,1,wsize(0)-110,wsize(3) } if wcolor(0)+wcolor(1)+wcolor(2)<=381:color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)):else:color 0.5*wcolor(0),0.5*wcolor(1),0.5*wcolor(2) pos 5,(wsize(3)-14)/2 font MSGothic,14,16 mes name+" - Wexblorer" repeat 100 gmode 3,1,wsize(3),255*cnt/100 pos wsize(0)-210+cnt,1 gcopy 3,0,0 loop color wcolor(0),wcolor(1),wcolor(2) boxf wsize(0)-109,1,wsize(0)-2,wsize(3)+1 color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)) boxf wsize(2),wsize(3)+1,wsize(0)-wsize(2)-1,wsize(3)+25 color 255,0,0 line wsize(0)-50,wsize(3)+1,wsize(0)-50,1 if wcolor(0)+wcolor(1)+wcolor(2)<=381:color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)):else:color 0.5*wcolor(0),0.5*wcolor(1),0.5*wcolor(2) line wsize(0)-80,wsize(3)+1,wsize(0)-80,1 line wsize(0)-110,wsize(3)+1,wsize(0)-110,1 line wsize(0)-21,(wsize(3)-10)/2,wsize(0)-31,(wsize(3)-10)/2+10 line wsize(0)-22,(wsize(3)-10)/2,wsize(0)-32,(wsize(3)-10)/2+10 line wsize(0)-32,(wsize(3)-10)/2,wsize(0)-22,(wsize(3)-10)/2+10 line wsize(0)-33,(wsize(3)-10)/2,wsize(0)-23,(wsize(3)-10)/2+10 color 192,192,192 line wsize(0)-wsize(2),wsize(3)+24,wsize(2),wsize(3)+24 color wcolor(0)/2,wcolor(1)/2,wcolor(2)/2 circle wsize(2)+2,wsize(3)+2,wsize(2)+22,wsize(3)+22 circle wsize(2)+22,wsize(3)+2,wsize(2)+42,wsize(3)+22 color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)) boxf wsize(2)+17,wsize(3)+2,wsize(2)+26,wsize(3)+22 boxf wsize(2)+10,wsize(3)+10,wsize(2)+33,wsize(3)+12 return #deffunc clchk stick clfr,256,256 if clfr&256:clickcnt++:else:clickcnt=0 return clickcnt #global #define defcls2 gmode 0,wsize(0),wsize(1),255:pos 0,0:gcopy 1,0,0 #define DIID_DWebBrowserEvents2 "{34A715A0-6587-11D0-924A-0020AFC7AC4D}" #define DISPID_COMMANDSTATECHANGE 105 #define DISPID_BEFORENAVIGATE2 250 #define DISPID_NAVIGATECOMPLETE2 252 #define DISPID_ONQUIT 253 #define DISPID_ONMENUBAR 256 #define DISPID_ONSTATUSBAR 257 #define DISPID_ONFULLSCREEN 258 #define DISPID_WINDOWSETLEFT 264 #define DISPID_WINDOWSETTOP 265 #define DISPID_WINDOWSETWIDTH 266 #define DISPID_WINDOWSETHEIGHT 267 #define DISPID_ONTHEATERMODE 260 dim wmenu,3 buffer 1,ginfo(20),ginfo(21) buffer 2,ginfo(20),ginfo(21) buffer 3,1,wsize(3) color wcolor(0),wcolor(1),wcolor(2) boxf buffer 4,ginfo(20),ginfo(21) buffer 5,ginfo(20),ginfo(21) bgscr 0,ginfo(20),ginfo(21) GetWindowLong hwnd, -16 SetWindowLong hwnd, -16, stat | $80000 | $10000 GetSystemMenu hwnd, 0 hSystemMenu = stat EnableMenuItem hSystemMenu,$F020,0 wpos=ginfo(4),ginfo(5) width wsize(0),wsize(1) sdim url,512 url="http://www.yahoo.co.jp" objsize wsize(0)-130-wsize(2),22 pos 130,wsize(3)+2 input url urlbox_id=stat urlbox_hn = objinfo(urlbox_id, 2) SetWindowLong urlbox_hn, -20, $0 ; スタイルを変えて SetWindowPos urlbox_hn, $27 ; 再描画 pos wsize(2),tsize axobj ie, "Shell.Explorer.2",wsize(0)-wsize(2)*2,wsize(1)-tsize-wsize(2) num=stat comevent ie_event, ie, DIID_DWebBrowserEvents2,*event ie->"Navigate" url oncmd gosub *event_WM_SIZE, 0x0005 *t_set gsel 1 defcls wsize,wcolor,name,loadingfrag gsel 2 defcls2 color 255,0,0 line wsize(0)-21,(wsize(3)-10)/2,wsize(0)-31,(wsize(3)-10)/2+10 line wsize(0)-22,(wsize(3)-10)/2,wsize(0)-32,(wsize(3)-10)/2+10 line wsize(0)-32,(wsize(3)-10)/2,wsize(0)-22,(wsize(3)-10)/2+10 line wsize(0)-33,(wsize(3)-10)/2,wsize(0)-23,(wsize(3)-10)/2+10 gsel 4 defcls2 color wcolor(0)/2,wcolor(1)/2,wcolor(2) circle wsize(2)+2,wsize(3)+2,wsize(2)+22,wsize(3)+22 color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)) boxf wsize(2)+17,wsize(3)+2,wsize(2)+26,wsize(3)+22 boxf wsize(2)+10,wsize(3)+10,wsize(2)+33,wsize(3)+12 gsel 5 defcls2 color wcolor(0)/2,wcolor(1)/2,wcolor(2) circle wsize(2)+22,wsize(3)+2,wsize(2)+42,wsize(3)+22 color wcolor(0)+0.5*(255-wcolor(0)),wcolor(1)+0.5*(255-wcolor(1)),wcolor(2)+0.5*(255-wcolor(2)) boxf wsize(2)+17,wsize(3)+2,wsize(2)+26,wsize(3)+22 boxf wsize(2)+10,wsize(3)+10,wsize(2)+33,wsize(3)+12 onffrag=1 gsel 0 *main if minimamfrag=1:gosub *minimam if exitfrag=1:goto *exit if oncfrag=1:oncfrag=0:goto *t_set wpos=ginfo(4),ginfo(5) mx2=ginfo(0) my2=ginfo(1) mx=mousex my=mousey pos 0,0 redfr=1 if (mx>=wsize(0)-50 and mx<=wsize(0) and my>=10 and my<=wsize(3)) or (mx>=wsize(0)-50 and mx<=wsize(0)-10 and my>=0 and my<=10):redfr=2 if mx>=wsize(2)+2 and mx<wsize(2)+22 and my>=wsize(3)+2 and my<wsize(3)+22:redfr=4 if mx>=wsize(2)+22 and mx<wsize(2)+42 and my>=wsize(3)+2 and my<wsize(3)+22:redfr=5 if redfrst!redfr or onffrag=1{ pos 0,0 gcopy redfr,0,0,wsize(0),wsize(1) redfrst=redfr onffrag=0 } clchk clcnt=stat if clcnt=0{ drfr=0 resizefrag=0 } if clcnt=1{ if mx>=wsize(0)-110 and mx<wsize(0)-80 and my>=0 and my<=wsize(3):minimamfrag=1 if (mx>=wsize(0)-50 and mx<=wsize(0) and my>=10 and my<=wsize(3)) or (mx>=wsize(0)-50 and mx<=wsize(0)-10 and my>=0 and my<=10):exitfrag=1 if my<=wsize(3) and my>=0.2*wsize(3) and mx<wsize(0)-110:drfr=1 if mx>=wsize(2)+2 and mx<wsize(2)+22 and my>=wsize(3)+2 and my<wsize(3)+22:goto *go_b if mx>=wsize(2)+22 and mx<wsize(2)+42 and my>=wsize(3)+2 and my<wsize(3)+22:goto *go_f //サイズ変更 if mx>=wsize(0)-wsize(2) and mx<=wsize(0) and my>=wsize(1)-wsize(2) and my<=wsize(1):resizefrag=1 if mx>=wsize(0)-wsize(2) and mx<=wsize(0) and my>wsize(3) and my<wsize(1)-wsize(2):resizefrag=2 if mx>wsize(0)-10 and mx<=wsize(0) and my>=0 and my<10:resizefrag=3 if mx>=wsize(2) and mx<wsize(0)-110 and my>=0 and my<0.2*wsize(3):resizefrag=4 if mx>=0 and mx<=wsize(2) and my>=0 and my<0.2*wsize(3):resizefrag=5 if mx>=0 and mx<=wsize(2) and my>0.2*wsize(3) and my<wsize(1)-wsize(2):resizefrag=6 if mx>=0 and mx<=wsize(2) and my>=wsize(1)-wsize(2) and my<=wsize(1):resizefrag=7 if mx>wsize(2) and mx<wsize(0)-wsize(2) and my>=wsize(1)-wsize(2) and my<=wsize(1):resizefrag=8 } if drfr=1{ sendmsg hwnd,$00A1,2,0 } if resizefrag=1 and (mx2!mx2stock or my2!my2stock){ width wsize(0)+mx2-mx2stock,wsize(1)+my2-my2stock gosub *event_WM_SIZE } if resizefrag=2 and mx2!mx2stock{ width wsize(0)+mx2-mx2stock gosub *event_WM_SIZE } if resizefrag=3 and (mx2!mx2stock or my2!my2stock){ width wsize(0)+mx2-mx2stock,wsize(1)-my2+my2stock,-1,limit(wpos(1)+my2-my2stock,0,ginfo(21)) gosub *event_WM_SIZE } if resizefrag=4 and my2!my2stock{ width wsize(0),wsize(1)-my2+my2stock,-1,limit(wpos(1)+my2-my2stock,0,ginfo(21)) gosub *event_WM_SIZE } if resizefrag=5 and (mx2!mx2stock or my2!my2stock){ width wsize(0)-mx2+mx2stock,wsize(1)-my2+my2stock,limit(wpos(0)+mx2-mx2stock,0,ginfo(20)),limit(wpos(1)+my2-my2stock,0,ginfo(21)) gosub *event_WM_SIZE } if resizefrag=6 and mx2!mx2stock{ width wsize(0)-mx2+mx2stock,wsize(1),limit(wpos(0)+mx2-mx2stock,0,ginfo(20)),-1 gosub *event_WM_SIZE } if resizefrag=7 and (mx2!mx2stock or my2!my2stock){ width wsize(0)-mx2+mx2stock,wsize(1)+my2-my2stock,limit(wpos(0)+mx2-mx2stock,0,ginfo(20)),-1 gosub *event_WM_SIZE } if resizefrag=8 and my2!my2stock{ width wsize(0),wsize(1)+my2-my2stock gosub *event_WM_SIZE } curid=0x7F00 if resizefrag=1 or (mx>=wsize(0)-wsize(2) and mx<=wsize(0) and my>=wsize(1)-wsize(2) and my<=wsize(1)):curid=0x7F82 if resizefrag=2 or (mx>=wsize(0)-wsize(2) and mx<=wsize(0) and my>wsize(3) and my<wsize(1)-wsize(2)):curid=0x7F84 if resizefrag=3 or (mx>wsize(0)-10 and mx<=wsize(0) and my>=0 and my<10):curid=0x7F83 if resizefrag=4 or (mx>10 and mx<=wsize(0)-110 and my>=0 and my<0.2*wsize(3)):curid=0x7F85 if resizefrag=5 or (mx>=0 and mx<=10 and my>=0 and my<0.2*wsize(3)):curid=0x7F82 if resizefrag=6 or (mx>=0 and mx<=10 and my>0.2*wsize(3) and my<wsize(1)-wsize(2)):curid=0x7F84 if resizefrag=7 or (mx>=0 and mx<=10 and my>=wsize(1)-wsize(2) and my<=wsize(1)):curid=0x7F83 if resizefrag=8 or (mx>=10 and mx<wsize(0)-110 and my>=wsize(1)-wsize(2) and my<=wsize(1)):curid=0x7F85 /*カーソルID一覧 通常 0x7F00 小砂時計 0x7F8A 砂時計 0x7F02 上向き矢印 0x7F04 左上右下矢印 0x7F82 右上左下矢印 0x7F83 左右矢印 0x7F84 上下矢印 0x7F85 全方向カーソル 0x7F86 禁止 0x7F88 指(リンク) 0x7F89 入力カーソル 0x7F01 十字カーソル 0x7F03 */ if curst!curid{ LoadCursor 0, curid SetClassLong hwnd, -12, stat curst=curid } mxstock=mx mystock=my mx2stock=mx2 my2stock=my2 await 10 goto *main *event ; COMイベント処理 dispid = comevdisp(ie_event) if dispid = DISPID_BEFORENAVIGATE2 : gosub *OnBeforeNavigate if dispid = DISPID_NAVIGATECOMPLETE2 : gosub *OnNavigateComplete2 if dispid = 250 : gosub *OnNavigateBefore2 return *OnBeforeNavigate comevarg name,ie_event,1 objprm 0,name return *OnNavigateComplete2 pDoc = ie("Document") name = pDoc("Title") title name delcom pDoc loadingfrag=0 oncfrag=1 return *OnNavigateBefore2 if silent="0":IE("Silent") = 1 loadingfrag=1 oncfrag=1 return *wow ie->"Navigate" url goto *main *go_f ie->"GoForward" goto *main *go_b ie->"GoBack" goto *main *refresh ie->"Refresh2" 3 goto *main *stop1 ie->"stop" goto *main *exit end *event_WM_SIZE wsize(0)=ginfo(12) wsize(1)=ginfo(13) dim fea,6 getobjsize fea,num fea(0)=wsize(0)-wsize(2)*2 fea(1)=wsize(1)-tsize-wsize(2) resizeobj num,fea getobjsize fea,urlbox_id fea(0)=wsize(0)-130-wsize(2) resizeobj urlbox_id,fea oncfrag=1 return *minimam sendmsg hwnd, $112, $F020 return



この記事に返信する


掘木

リンク

2013/11/24(Sun) 18:25:55|NO.58444

ソースの軽量化が望まれます。できる限り小さい状態でテストしてみよう。
IEのcomの利用以前のbgscrのみでテストはしたのでしょうか?

タスクボタンでの最小化に関しては、
ウィンドウスタイルにWS_MINIMIZEBOXを追加することでそれっぽい挙動を確認できました。

minimamfragが初期化されていません。
一度最小化すると1のままで復元に成功しても即座に最小化されてしまうでしょう。


bgscrでのテストをいろいろやってみました。多分動くのではないかと。
オマケはそのまま切り捨ててもらって構いません(ぁ

#uselib "user32.dll" #func global SetWindowLongA "SetWindowLongA" int , int , int #cfunc global GetWindowLongA "GetWindowLongA" int , int #define global GetWindowLong GetWindowLongA #define global SetWindowLong SetWindowLongA #define global GWL_STYLE 0xFFFFFFF0 #define global WS_SYSMENU 0x00080000 #define global WS_MAXIMIZEBOX 0x00010000 #define global WS_MINIMIZEBOX 0x00020000 bgscr 0,320,240,,320,240//bgscrでウィンドウ作成 cls 1 // 分かりづらいので灰色にしておく。 SetWindowLong hwnd,GWL_STYLE,WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|GetWindowLong(hwnd,GWL_STYLE) //------------------------------------------------------------------------------ //  以下オマケ 直接WINDOWSに擬似ボタンを最小化ボタンのように認識させるテスト //------------------------------------------------------------------------------ #const MINBOX_X 320-48+2 #const MAXBOX_X 320-32+2 #const CLOSEBOX_X 320-16+2 #const SYSBOX_Y 2 #const SYSBOX_WIDTH 12 #const SYSBOX_HEIGHT 12 #define blockf(%1,%2,%3,%4) boxf %1,%2,(%1)+(%3)-1,(%2)+(%4)-1 #define ctype InBlock(%1,%2,%3,%4,%5,%6) ( limit(%1,%3,(%3)+(%5))==(%1) && limit(%2,%4,(%4)+(%6))==(%2) ) #define WM_NCHITTEST 0x0084 #define HTMINBUTTON 8 #define HTMAXBUTTON 9 #define HTCLOSE 20 color 255,128,128 blockf MINBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT color 128,255,128 blockf MAXBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT color 128,128,255 blockf CLOSEBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT oncmd gosub *nchittest,WM_NCHITTEST stop *nchittest mx = (lparam&0xFFFF)-ginfo(4) my = (lparam>>16)-ginfo(5) if InBlock(mx,my,MINBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT) : return HTMINBUTTON if InBlock(mx,my,MAXBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT) : return HTMAXBUTTON if InBlock(mx,my,CLOSEBOX_X,SYSBOX_Y,SYSBOX_WIDTH,SYSBOX_HEIGHT) : return HTCLOSE return 1 // WM_NCHITTESTの返り値を書き換えることで、 // さながら標準ウィンドウの上にマウスが乗っているかのように振る舞うことはできる。 // // しかしクリック時にも適用されるためクリックした時点でなんかボタンが表示されて見栄え悪い・・・。 // このボタンを出さないことができればもっと応用が利きそう。



fortunehill

リンク

2013/11/25(Mon) 00:30:50|NO.58457

/*ご参考(ヒント)*/

*main if minimamfrag=1:gosub *minimam ;最小化ボタンを押すと毎回此処が有効になっている(無限ループ) ;ウインドウ位置が-32000,-32000と成る *minimam minimamfrag=0 ;フラグをリセットしておけば元のサイズに戻せる様に成るが ;根本的な解決策では無い sendmsg hwnd,$112,$F020 return



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