|
|
2015/8/7(Fri) 09:17:37|NO.70538
Windows10で
BlurBehindWindowが有効な時にガラス効果が掛かったウインドウを表示したいのですが・・・
まず、エアロが有効かどうか調べて・・・
#uselib "dwmapi.dll"
#func DwmIsCompositionEnabled "DwmIsCompositionEnabled" var
#define WM_DWMCOMPOSITIONCHANGED 0x031E
DwmIsCompositionEnabled AeroEnable
if (stat == 0) {
if (AeroEnable == 1) : mes "AeroEnable"
else if : mes "AeroDisable"
stop
有効だったらブラービハインドウインドウを表示させたいのでが・・・
上手く行きません。
#uselib "dwmapi.dll"
#func defica "DwmExtendFrameIntoClientArea" int, var
cls 4 //黒で通常のガラス効果が得られる
margins = -1, 0, 0, 0 //-1 を指定するとウィンドウ全体
defica hwnd, margins
stop
Windows10でもHSPでガラス効果が
得られるように修正して頂けると大変嬉しいのですが・・・
|
|
2015/8/7(Fri) 16:12:51|NO.70542
今のところmsdnでWin 10用aero apiもないし他言語でも成功した人がいないから
もう少し待ってみたらできるかも
少し特殊な使用のようです。
|
|
2015/8/7(Fri) 16:16:58|NO.70543
Windows 8や10ではAeroとしては後ろが透けないみたいです。
自前で透過ウィンドウを用意するしかなさそうですが、
それだとブラー効果を再現するのは難しそうです。
|
|
2015/8/7(Fri) 16:35:04|NO.70544
#uselib "user32.dll"
#func GetWindowLongA "GetWindowLongA" int , int
#func SetWindowLongA "SetWindowLongA" int , int , int
#func SetLayered "SetLayeredWindowAttributes" int , int , int , int
#uselib "dwmapi.dll"
#func defica "DwmExtendFrameIntoClientArea" int, var
#func DwmEnableBlurBehindWindow "DwmEnableBlurBehindWindow" int ,var
GetWindowLongA hwnd , -20
SetWindowLongA hwnd , -20 , stat | 0x00080000
SetLayered hwnd , 0 , 50*255/100 , 2
cls 4
margins = 0, 0, -1, 25 //-1 を指定するとウィンドウ全体
bb = 1,1
DwmEnableBlurBehindWindow hwnd,bb
//defica hwnd, margins
stop
透過したあとにDwmEnableBlurBehindWindow でブラーをかけています。
|
|
2015/8/7(Fri) 16:36:13|NO.70545
↑は無しでブラーがおかしいみたい
|
|
2015/8/7(Fri) 17:28:06|NO.70546
画面キャプってOpenCVでブラー掛けて表示・・・が今のところ楽だと思う。
ただ自ウィンドウの後ろをキャプるとなるともの凄く面倒らしいから、
起動時に自ウィンドウが表示される前に1回キャプってそれを使いまわす、って感じが最善かな?
|
|
2015/8/7(Fri) 17:43:11|NO.70547
雑ですが何かの参考になれば。
#include "hspcv.as"
#uselib "gdi32.dll"
#cfunc CreateDC "CreateDCA" sptr,sptr,sptr,int
#func DeleteDC "DeleteDC" int
#func BitBlt "BitBlt" int,int,int,int,int,int,int,int,int
#define NULL 0
#define SRCCOPY 0x00CC0020
#define CAPTUREBLT 0x40000000
gsel 0,-1:await 500
; デスクトップ画面のサイズでバッファ画面を作成
sx = ginfo_dispx : sy = ginfo_dispy
buffer 2, sx, sy
; デスクトップ画面のデバイスコンテキスト取得
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL)
; デスクトップ画面の画像をコピー
BitBlt hdc, 0, 0, sx, sy, hdcScreen, 0, 0, SRCCOPY | CAPTUREBLT
; デバイスコンテキスト削除
DeleteDC hdcScreen
cvbuffer 0,sx,sy//CVbufferを初期化
cvputimg 0//CVbufferにキャプった画像をコピー
cvsmooth CV_GAUSSIAN,21,21,0//ぼかしを掛ける
Buffer 3,sx,sy
cvgetimg 0,0//ぼかした画像をBufferにコピー
bgscr 0,500,500
pos 4,4
Color 255,255,255:boxf:Color 0,0,0:boxf 2,2,498,498
repeat
getkey k,1
getkey esc,27
if esc=1:end
if k=1&kbac=0&ginfo_sel=0:移動フラグ=1:dmx=mousex:dmy=mousey//ドラック始め
if k=0&kbac=1&ginfo_sel=0:移動フラグ=0//ドラック終了
if 移動フラグ=1:width ,,ginfo_mx-dmx,ginfo_my-dmy//ドラック中
gcopy 3,ginfo_wx1+4,ginfo_wy1+4,492,492//描画
kbac=k
await 17-(cnt\3=0)//リフレに合わせるのがコツ
loop

| |
|
2015/8/7(Fri) 18:11:39|NO.70548
どうやら
SetWindowCompositionAttributeを使用することで
半透明化→ブラーが可能なようです。
サンプル用意中
|
|
2015/8/7(Fri) 20:45:20|NO.70549
|
|
2015/8/7(Fri) 21:26:18|NO.70550
そういや仮想環境にWindows 10のInsider Previewを入れてたなあ、と思いだしたので
コード書いてる時間よりもWindows 10の起動時間のほうが長いという…orz
#uselib "User32.dll"
#func SetWindowCompositionAttribute "SetWindowCompositionAttribute" int, var
#define WCA_ACCENT_POLICY 19
#define ACCENT_DISABLED 0
#define ACCENT_ENABLE_GRADIENT 1
#define ACCENT_ENABLE_TRANSPARENTGRADIENT 2
#define ACCENT_ENABLE_BLURBEHIND 3
#define ACCENT_INVALID_STATE 4
dim accent, 4/*AccentPolicy*/
accent(0) = ACCENT_ENABLE_BLURBEHIND
dim data, 3/*WindowCompositionAttributeData*/
data(0) = WCA_ACCENT_POLICY
data(2) = 16/*accentStructSize*/
data(1) = varptr(accent)
SetWindowCompositionAttribute hwnd, data
// 以下おまけ
// 関数の戻り値(0以外なら正常)
title str(stat)
// 黒背景
color 0, 0, 0
boxf
// なんか描いてみる
color 255, 0, 0
boxf 100, 100, 300, 300
color 0, 127, 255
circle 300, 250, 500, 450
color 255, 255, 255
boxf 250, 250, 350, 350
ちなみにUX的にはOSが用意したデザインをプログラマーが変更することはあまり好ましくないと思います。
|
|
2015/8/8(Sat) 11:50:06|NO.70557
皆様ありがとうございます。
Windows10でエアロが復活したと聞いてはいましたが、
そんなに単純ではなかったみたいですね。
スペース様・・・エアロってのはこんな複雑な動作を瞬時にやってしまうのですね。
ですので確かにOSが用意したデザインを変更するのはあんまり良くはないですね。
|
|