SetLayeredWindowAttributes not working on Windows 7

本小妞迷上赌 提交于 2019-12-19 04:07:56

问题


I am using SetLayeredWindowAttributer to make a particular color of layered window transparent.

This works fine on Windows XP,VISTA . But when I use the same on Windows 7 its not working.

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

When I use LWA_ALPHA then also it works. Problem is that I am not able to make a particular color transparent in Windows 7.

The following statement works on Windows 7

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

Is it possible that the rendered color values not matching the color value in SetLayeredWindowAttributes?


回答1:


You should avoid using 0xff,0xff,0xff (white) with LWA_COLORKEY. Any other value should be fine (e.g. 0xff,0xff,0xfe).

For more control over your layered window I suggest you consider using UpdateLayeredWindowIndirect. I wrote an article that describes in detail how it can be used with both GDI and Direct2D.

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



来源:https://stackoverflow.com/questions/3967003/setlayeredwindowattributes-not-working-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!