SetLayeredWindowAttributes not working on Windows 7
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,R开发者_StackOverflowGB(0xff,0xff,0xff), 100, LWA_ALPHA);
Is it possible that the rendered color values not matching the color value in SetLayeredWindowAttributes?
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
精彩评论