Intro.
Hi all, you should be familiar with soo many shellpacks and themes for WindowsXP floating around internet from its initial release. Its a good factor, WindowsXP can be skinned or themed. And, when the sucessor to Microsoft's NT 5.1 (XP), Windows Vista (NT version 6.0) came out, it came with translucent glass efects on Windows Taskbar and Titlebars. The theme guys were after translucency from the time right Microsoft Announced Vista. And, surprisingly enough, i also got some themes for WindowsXP which provided Translucent taskbar and titlebar makeing it a wonderful effect in WindowsXP. Well, in Transparency, what made my mind struck is the Taskbar of Windows Vista. The Theme makers had suceeded to imitate it exactly, and almost exactly in WIndowsXP. One of those themes i like is GlassXP, and another is Vistamizer. Okay, if they can make transparent Taskbar in WindowsXP, then definitely WindowsXP supports that feature. Now, I'm showing you how to achieve Taskbar transparency in WindowsXP using Visual C++ and Windows API's. Here comes the Alpha Blending function of Windows. From Windows version 200 onwards, you can control Alpha values of every window using SetLayeredWindowAttributes() API. And, there's no much bulky codes to do this... just a single API call can make a Taskbar transparent. This works with Windows2000(NT)+ Platforms only. This wont work in WIndows95/98/ME. :)
How to do.
The Microsoft WIndows versions ranging from 2000 onwards supports Alpha Blended transparency for a window. In Windows programming, each and every "Window" has its own properties as well as standard window properties and has a unique "classname". The Taskbar is also a window. So, we can surely use classname of Taskbar to find it as a window, identify and alphablend it. The classname of Windows Taskbar is "Shell_TrayWnd". So, first we will find a Window with classname "Shell_TrayWnd" using FindWindow() API call to retrieve the HWND or handle to the Window. Alpha Blending requires it to be done on "Layered Windows" or window created with WS_EX_LAYERED flag. We dont know whether taskbar is created with Layered attributes or not. Anyway, lets do it if its not. We use GetWindowLong() API with flag GWL_EXSTYLE and handle of taskbar, which will return a DWORD value representing style atributes of current Window(in our case, taskbar). We will Logically OR it with WS_EX_LAYERED and pass it to SetWindowLong() which will make the Window to set WS_EX_LAYERED flag along with its other style attributes. Okay, now we can call SetWindowLayeredAttributes() and pass in an Alpha value between 0 to 255 as we needed for the taskbar transparency. 0 makes the Taskbar/Window Completely transparent and it will be invisible. 255 makes the window Opaque. Here, i'm using 200 As Alpha value for my Taskbar. and I've used the WindowsXP's Silver color scheme as i feel it more good :)
Hi all, you should be familiar with soo many shellpacks and themes for WindowsXP floating around internet from its initial release. Its a good factor, WindowsXP can be skinned or themed. And, when the sucessor to Microsoft's NT 5.1 (XP), Windows Vista (NT version 6.0) came out, it came with translucent glass efects on Windows Taskbar and Titlebars. The theme guys were after translucency from the time right Microsoft Announced Vista. And, surprisingly enough, i also got some themes for WindowsXP which provided Translucent taskbar and titlebar makeing it a wonderful effect in WindowsXP. Well, in Transparency, what made my mind struck is the Taskbar of Windows Vista. The Theme makers had suceeded to imitate it exactly, and almost exactly in WIndowsXP. One of those themes i like is GlassXP, and another is Vistamizer. Okay, if they can make transparent Taskbar in WindowsXP, then definitely WindowsXP supports that feature. Now, I'm showing you how to achieve Taskbar transparency in WindowsXP using Visual C++ and Windows API's. Here comes the Alpha Blending function of Windows. From Windows version 200 onwards, you can control Alpha values of every window using SetLayeredWindowAttributes() API. And, there's no much bulky codes to do this... just a single API call can make a Taskbar transparent. This works with Windows2000(NT)+ Platforms only. This wont work in WIndows95/98/ME. :)
How to do.
The Microsoft WIndows versions ranging from 2000 onwards supports Alpha Blended transparency for a window. In Windows programming, each and every "Window" has its own properties as well as standard window properties and has a unique "classname". The Taskbar is also a window. So, we can surely use classname of Taskbar to find it as a window, identify and alphablend it. The classname of Windows Taskbar is "Shell_TrayWnd". So, first we will find a Window with classname "Shell_TrayWnd" using FindWindow() API call to retrieve the HWND or handle to the Window. Alpha Blending requires it to be done on "Layered Windows" or window created with WS_EX_LAYERED flag. We dont know whether taskbar is created with Layered attributes or not. Anyway, lets do it if its not. We use GetWindowLong() API with flag GWL_EXSTYLE and handle of taskbar, which will return a DWORD value representing style atributes of current Window(in our case, taskbar). We will Logically OR it with WS_EX_LAYERED and pass it to SetWindowLong() which will make the Window to set WS_EX_LAYERED flag along with its other style attributes. Okay, now we can call SetWindowLayeredAttributes() and pass in an Alpha value between 0 to 255 as we needed for the taskbar transparency. 0 makes the Taskbar/Window Completely transparent and it will be invisible. 255 makes the window Opaque. Here, i'm using 200 As Alpha value for my Taskbar. and I've used the WindowsXP's Silver color scheme as i feel it more good :)
Code.
Well, its time for some code :
HWND hTaskBar;
DWORD dwStyle;
hTaskBar = FindWindow( _T( "Shell_TrayWnd" ), 0 );
dwStyle = GetWindowLong( hTaskBar, GWL_EXSTYLE );
SetWindowLong( hTaskBar, GWL_EXSTYLE, dwStyle WS_EX_LAYERED );
//Now, lets apply Transparency(Alpha adjustment) for our Taskbar Window.
SetLayeredWindowAttributes( hTaskBar, 0, 200 , LWA_ALPHA );
//Adjust the 3rd parameter to adjust transparency as you need.
Lol, liked it? Dont forget to give Feedback ;-)
PS : The method shown here is a Alpha Blending method of just how to create a transparent Window. Transparency and Glass Efect are two different variety. You cannot create "Glass Effect" using this method. Microsoft Windows Vista/Windows7 are/may not be using this method for creating Glass effects on Windows Titlebars and Taskbar. This is a method to emulate transparency in WindowsXP/2000 only. There are various other methods to achieve real transparency, this is a basic one. Enjoy :)
No comments:
Post a Comment