Transparent Window using SetLayeredWindowAttributes
-
hello all i am using VS 6.0, VC++, Win32 My Task is to display png image on Transparent window..... i used SetLayeredWindowAttributes to make my window transparent and it works fine......but the problem is my image also gets transparent and nothing is displayed ...... can anybody suggest me how to overcome this problem.....i.e only window should become transparent but not the image..... Thankx:::
-
hello all i am using VS 6.0, VC++, Win32 My Task is to display png image on Transparent window..... i used SetLayeredWindowAttributes to make my window transparent and it works fine......but the problem is my image also gets transparent and nothing is displayed ...... can anybody suggest me how to overcome this problem.....i.e only window should become transparent but not the image..... Thankx:::
You can use an image with a solid colour applied in the parts that should be transparent. You then display the image using alpha keying, which renders the image except pixels that are this colour. Here is code that displays an an image with 75% opacity, except for pixels that are RGB(255,0,0) - which are not displayed at all.
SetLayeredWindowAttributes(hwnd, RGB(255,0,0), (75*255)/100, ULW_COLORKEY|LWA_ALPHA);
If you remove the|LWA_ALPHA
part, you get full opacity on all pixels except the red ones, which are not shown at all. -
You can use an image with a solid colour applied in the parts that should be transparent. You then display the image using alpha keying, which renders the image except pixels that are this colour. Here is code that displays an an image with 75% opacity, except for pixels that are RGB(255,0,0) - which are not displayed at all.
SetLayeredWindowAttributes(hwnd, RGB(255,0,0), (75*255)/100, ULW_COLORKEY|LWA_ALPHA);
If you remove the|LWA_ALPHA
part, you get full opacity on all pixels except the red ones, which are not shown at all. -
Oops, sorry about that - i forget which one it is, you need one of these #defines (I think it's the first one) #define _WIN32_WINNT 0x0601 #define _WIN32_IE 0x0300
-
in both #defines i got the same error as error C2065: 'ULW_COLORKEY' : undeclared identifier
I think you need one of these (put that into the PreProcessor settings of your project): _WIN32_IE=0x0500 WINVER=0x0500
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
-
in both #defines i got the same error as error C2065: 'ULW_COLORKEY' : undeclared identifier