Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GacUI是否支持透明窗口 #42

Open
krasewallet opened this issue Sep 26, 2019 · 6 comments
Open

GacUI是否支持透明窗口 #42

krasewallet opened this issue Sep 26, 2019 · 6 comments
Labels
2.0 This will be fixed in GacUI 2.0 enhancement

Comments

@krasewallet
Copy link

GDI+ 结合 updateLayeredwindow可以实现透明窗口的效果,GacUI 是否也支持透明窗口的D2D渲染?看了下代码和样例,只大概看明白了 D3D结合D2D绘制窗口过程,没有发现透明窗口支持部分

@vczh
Copy link
Member

vczh commented Oct 1, 2019

没有直接支持,你可以用GacUIWindows.h里面的vl::presentation::windows::GetWindowsForm,拿到HWND然后调用API来做。

@vczh vczh added the 2.0 This will be fixed in GacUI 2.0 label Oct 4, 2019
@TonyDragonlake
Copy link

Direct2DWindowsNativeWindowListener_1_0里Alpha通道是可以通过设置D2D1_RENDER_TARGET_PROPERTIES属性设置的(GacUI/Source/NativeWindow/Windows/Direct2D/WinDirect2DApplication.cpp,第97行),然后只要用DwmEnableBlurBehindWindow就可以把底色去掉;
Direct2DWindowsNativeWindowListener_1_1里设置的交换链,即使在D2D1::BitmapProperties1设置允许Alpha通道(GacUI/Source/NativeWindow/Windows/Direct2D/WinDirect2DApplication.cpp,第242行),貌似也没办法把窗口变透明(试了一下,d2d的bitmap是透明了,但是后面有底色,应该是D3D的);然后尝试在交换链中设置透明,但是报错了,提示说只能在CreateSwapChainForCoreWindow或者WindowCompition才能设置AlphaMode,其两者都是要有窗口扩展样式WS_EX_NOREDIRECTIONBITMAP,该样式不支持win7系统。

@vczh
Copy link
Member

vczh commented Mar 23, 2020

@TonyDragonlake 我学习一下,不过我记得你可以直接设置窗口的透明色吧,D2D渲染上去什么都可以,感觉不需要在D2D的这一层做。不过这样可能不支持磨砂玻璃效果。

@TonyDragonlake
Copy link

非常感谢。
尽管使用DirectComposition可以透明,但是仍然需要win8及以上版本,且要有窗口扩展样式WS_EX_NOREDIRECTIONBITMAP用来设定不使用重定向表面。
这篇文章中 “Window Layering” 似乎容易令人误解。似乎文中没有提到DirectComposition与LayeredWindow的交互方式,且DirectComposition似乎没办法做到和gdi中UpdateLayeredWindow函数所能做到的 “鼠标穿透Alpha为0的区域”的功能。

@vczh
Copy link
Member

vczh commented Apr 20, 2020

@TonyDragonlake 这篇文章是给D2D渲染用的,GDI的话从vista开始就支持设置图片作为背景的同时用alpha通道作为每一个像素的透明度的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 This will be fixed in GacUI 2.0 enhancement
Projects
None yet
Development

No branches or pull requests

3 participants