Click here to Skip to main content
15,883,831 members
Articles / Programming Languages / XML

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

Rate me:
Please Sign up or sign in to vote.
1.88/5 (13 votes)
6 May 20053 min read 88.2K   2.3K   13   7
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.

Image 3

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 leave a comment below.

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.


Written By
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 Pin
Burak Tunçbilek27-Jul-12 6:07
Burak Tunçbilek27-Jul-12 6:07 
GeneralGreat article, But I have a question Pin
chinese_zmm7-Apr-09 21:06
chinese_zmm7-Apr-09 21:06 
GeneralMy vote of 2 Pin
Andreas_19834-Feb-09 5:14
Andreas_19834-Feb-09 5:14 
GeneralVC++.net 2003 Pin
minad_7865-Sep-07 5:58
minad_7865-Sep-07 5:58 
GeneralNot unique to 2005 Pin
fwsouthern9-May-05 17:50
fwsouthern9-May-05 17:50 
GeneralRe: Not unique to 2005 Pin
ashish_patil++25-May-05 1:39
ashish_patil++25-May-05 1:39 
GeneralStupidity 101 revisited Pin
fwsouthern10-Aug-05 17:31
fwsouthern10-Aug-05 17:31 

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

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