winapi - SetLayeredWindowAttributes与LWA_COLORKEY只设置像素完全不透明或完全透明? [英] winapi - SetLayeredWindowAttributes with LWA_COLORKEY only sets pixels to either fully opaque or fully transparent?
问题描述
我的框架边框为白色(0xfffffffe)。我的框架内部是黑色的(0xff000000)。
我想让边框半透明(alpha值为100),内部不透明。显然,我使用 SetLayeredWindowAttributes
这样做,但它不工作。
The border of my frame is white (0xfffffffe). The interior of my frame is black (0xff000000).
I want to make the border translucent (alpha value of 100), and the interior opaque. Obviously, I've used SetLayeredWindowAttributes
to do this, but it's not working.
这个变化: SetLayeredWindowAttributes(RGB(0xxff,0xff,0xfe),100,LWA_COLORKEY)
将边框设置为alpha的100,但内部是完全透明的。
This variation: SetLayeredWindowAttributes(RGB(0xxff, 0xff, 0xfe), 100, LWA_COLORKEY)
sets the border to alpha of 100, but the interior as completely transparent.
此变体: SetLayeredWindowAttributes(RGB(0xxff,0xff,0xfe),100,LWA_COLORKEY | LWA_ALPHA)
将内部设置为alpha的100,
This variation: SetLayeredWindowAttributes(RGB(0xxff, 0xff, 0xfe), 100, LWA_COLORKEY | LWA_ALPHA)
sets the interior to an alpha of 100, but sets the border as completely transparet.
如何使内部不透明和边框透明?我不能使用多个顶级窗口来实现这种情况下的影响。
How can I make the interior opaque and the border transparent? I can't use multiple top-level windows to achieve the affect in this situation.
推荐答案
而不是 SetLayeredWindowAttributes
,使用 UpdateLayeredWindow
。您可以将整个帧(包括任何透明度)预先渲染到32位位图上,将其选择为DC,并将其传递给 UpdateLayeredWindow
。
这篇关于winapi - SetLayeredWindowAttributes与LWA_COLORKEY只设置像素完全不透明或完全透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!