Hi all, This one, i've searched in many forums and Googled for a solution. I'm a lazy programmer.. lolz.. so, i sit in front of google for a fully cooked code for hours.. but the results were of in vein which cooked up my ass. There are a lot of codes and samples in CG Forums, CodeProject and all, but they were about Transparent window in MFC. I'm not an MFC programmer, i'm Win32 VC++ programmer, so i've no use in getting MFC codes. So, I decided to do it myself.. i just referenced MSDN and find out the way. itz nothing that Huge as you think.. just 3-4 lines of code can do it for you.. just believe me.. i'll show you how..
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
dwStyle = dwStyle WS_EX_LAYERED;
SetWindowLong(hWnd, GWL_EXSTYLE, dwStyle);
SetLayeredWindowAttributes(hWnd, 0, 240 , LWA_ALPHA);
..can do it for you.. itz nothing.. i'll describe in brief:
1)DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
GetWindowLong() API is used to get the current style propery attributes of our window, where hWnd is the Window's Handle.
2)dwStyle = dwStyle WS_EX_LAYERED;
We are OR-ing the current styles of our Window with a style WS_ES_LAYERED. So that, if that styled is not applied it will get applied.
3)SetWindowLong(hWnd, GWL_EXSTYLE, dwStyle);
Nextly we are setting that Layered style to our Window using SetWindowLong() API.
4)SetLayeredWindowAttributes(hWnd, 0, 180 , LWA_ALPHA);
The Transparancy is achieved by decrementing the ALPHA values of our Window atributes. Here 180 is the Alpha value i have set for transparancy. You can decrease it for more transparancy, and increase it to make the window Opaque.
Mail me to : jithinpg007@live.com if you like the posts.. :-)
Search This Blog
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment