anand
anand

Reputation: 11349

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,RGB(0xff,0xff,0xff), 100, LWA_ALPHA);

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

Upvotes: 3

Views: 6017

Answers (1)

Kenny Kerr
Kenny Kerr

Reputation: 3115

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

Upvotes: 2

Related Questions