Friday, March 23, 2012

transparency: aero like effect–windows forms

The NEED:
For PC’s having Windows XP,98 it is not possible to bring in aero effects like Transparency. Since these operating systems don’t have sufficient resources, achieving both backward compatibility and superior aesthetics is going to be really difficult. Therefore workaround’s are the only option.
SMALL STORY:
I was designing a Windows form application – an assignment given by my professor. I wanted to make it backward compatible as he has a system running Windows XP. But I badly wanted to include the Glass effect (found in AERO), since I wanted my user interface  to look really beautiful. So I started looking for workaround’s. I did manage to find one(made me look like a complete idiot, since I couldn’t think of such a simple thing) . I am going to talk about the same in this blog post.
Prerequisites: Visual Studio
METHOD:
Consider a sample Windows 7 form:
It looks like this, completely opaque. To give it some Transparency, view the form’s design(Design view).  Click on the form ( such that the form gets selected not the controls inside the form) and view its properties ( You can do this by click the properties tab available on the right hand side of Visual studio or if its not present press CTRL + W,P). Now scroll down and find the property called Opacity. By default this will be set to 100%. Set this to 90%.
And there you go, you are done. Now press F5 and you can see your form having the beautiful transparency effect. You can adjust the value of opacity to vary the degree of transparency, but make sure you don’t increase transparency to an extent where content cannot be seen.
CONCLUSION:
You can see that the transparency effect has made the UI really better. Try changing the color that suits your application and transparency. This process makes the control’s inside the form(almost all) to exhibit transparency. This can be used in Windows 7 and vista also, if you think that using those Aero DLL’s is a tedious process.
Download the sample source code here. Here I have varied the transparency based on a track bar.

0 comments:

Post a Comment