SetLayeredWindowAttributes无法在Windows 7上工作

问题描述:

我使用SetLayeredWindowAttributer使分层窗口的特定颜色透明。SetLayeredWindowAttributes无法在Windows 7上工作

这适用于Windows XP,VISTA。但是当我在Windows 7上使用它时,它不起作用。

SetLayeredWindowAttributes(hWnd, RGB(0xff,0xff,0xff), 0, LWA_COLORKEY); 

当我使用LWA_ALPHA时,它也可以。 问题是,我不能够做一个特定的颜色透明在Windows 7

下面的语句可以在Windows 7

SetLayeredWindowAttributes(hWnd,RGB(0xff,0xff,0xff), 100, LWA_ALPHA); 

是否有可能呈现的颜色值不匹配的颜色值SetLayeredWindowAttributes?

您应该避免在LWA_COLORKEY中使用0xff,0xff,0xff(白色)。任何其他值应该都可以(例如,0xff,0xff,0xfe)。

为了更好的控制你的分层窗口,我建议你考虑使用UpdateLayeredWindowIndirect。我写了一篇文章,详细描述了它如何与GDI和Direct2D一起使用。

http://msdn.microsoft.com/en-us/magazine/ee819134.aspx