Click here to Skip to main content
Click here to Skip to main content
Go to top

Transparency and Opacity Experiments with .NET's Web Browser Control

, 6 May 2005
Rate this:
Please Sign up or sign in to vote.
This application is nothing more than an IEControl hosted on a Windows Form and some code to get it to life. By setting opacity and transparency key of the form, one can actually make the content inside the window translucent or transparent .

Sample image

Introduction

First, let me accept that .NET is really cool. It certainly accelerates development time multifold. Also, it has very powerful features that can be used very easily. Microsoft has started to give 'Express Edition' of its development tool free of cost, which I believe is the best thing that can ever happen to .NET. I just happened to get my hands on the Visual C# 2005 Express Edition (Beta) and was amazed !!

Transparency and opacity are nothing new to all those who have used Windows Forms in .NET. I have done lot of experiments with them, but this one is awesome. This application is nothing more than an IE control hosted on a Windows Form and some code to get it to life. By setting opacity and transparency key of the form, one can actually make the content inside the window translucent or transparent. The results are mind-blowing, have a look:

Sample image

Browsing with translucent background.

Directory browsing with transparency key 'White'.

How it works

The application is a fairly simple one. As I said all it has is an IE control . The border style of the from is set to 'sizeable tool window'. The application is operated using commandline parameters.

TransparentIE URL [opacity] [sizex] [sizey] [r] [g] [b] 
TransparentIE URL [0.0-1.0] [0-1024] [0-1024] [0-255] [0-255][0-255]

The URL is the URL or file path we want the application to point to. Opacity should be between 0.0 and 1.0. Also size of the window can be specified optionally. The last three parameters are R,G,B values of the color which we want transparent. For example:

TransparentIE C:\Temp 1.0 100 100 255 255 255 

Will open ‘C:\Temp’ for directory browsing with opaque background, in a window of size 100x100 with white as transparent color. Only the first parameter is compulsory. You can move or resize the window using mouse, once it is displayed. I think this is a great technique.

Sample image

Directory browsing with translucent background.

Sample image

Browsing with translucent background.

Doing More Interesting Things

It is not just limited to web pages and directory browsing. Imagine what ActiveX and DHTML can do to it. For example you can read a PDF just by pointing your browser to PDF. You can even have these effects on Java applets or basically any type of plug-in that works with IE. Isn’t that great.

Using this technique with carefully constructed DHTML content will make it look awesome. One interesting thing that I have noted is, when you have a transparency set, you can actually click icons or anything else in background through the transparent window. That again is cool!!

Viewing PDF document with translucent background.

However at times when the content is bulky, it does slow down things a bit. Like if you have a big graphic inside the window. Also after some experimentation I realized that transparency is best used with custom made web pages. Using transparency on photos or high color graphics, gives ugly looking white borders to opaque areas. Even then there is absolutely no limit with what one can do with this. Try using DHTML filters, animated gifs, custom designed web pages, activex controls, plug-ins and Java applets with this. If you come up with something spectacular do send me a screenshot.

There is nothing much in the code of this application. If you are a .NET programmer, you will be able to put up such an application in no time. If you still required code or the binaries, please mail me.

Hope you found this post interesting and beautiful!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

ashish_patil++
Web Developer
India India
Ashish is an Electronics Engineer. He loves computers and programming, and always tries to do something different. Ashish started his programming career with FoxPro 2.5 (6 years ago) .Ashish has programmed in number of languages including C\C++ , Tcl\Tk , Assembly Language , JavaScript. Currently he works with ASP.NET, C# and VB.NET. He is currently working in multinational consulting company in India.
 
He devotes much of his free time to his website: http://ashishware.com , which contains lot of cool stuff on webdevelopment and programing in general.

Comments and Discussions

 
GeneralMy vote of 4 PinmemberBurak Tunçbilek27-Jul-12 6:07 
GeneralGreat article, But I have a question Pinmemberchinese_zmm7-Apr-09 21:06 
GeneralMy vote of 2 PinmemberMember 57865694-Feb-09 5:14 
GeneralVC++.net 2003 Pinmemberminad_7865-Sep-07 5:58 
GeneralNot unique to 2005 Pinmemberfwsouthern9-May-05 17:50 
GeneralRe: Not unique to 2005 Pinmemberashish_patil++25-May-05 1:39 
GeneralStupidity 101 revisited Pinmemberfwsouthern10-Aug-05 17:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 6 May 2005
Article Copyright 2005 by ashish_patil++
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid