Click here to Skip to main content
13,804,063 members
Click here to Skip to main content
Add your own
alternative version


145 bookmarked
Posted 26 May 2005

Transparent Desktop Video

, 26 May 2005
Rate this:
Please Sign up or sign in to vote.
Transparent video overlay over the Windows desktop.

Sample screenshot


This simple C# WinForms project allows you to playback video from a live capture device or from an existing video file and blend the video using transparency with the existing Windows desktop. The user can still interact with all other application windows "through" the playing video stream.


A while ago, a group from the University of North Carolina published a paper detailing a system they called FaceTop that makes use of transparent video streams for use in collaboration environments. By using transparent video over the desktop, the participant can view a video stream of the other participant while at the same time being able to read the contents of their desktop and look at items on their desktop that the other participant is referring to.

FaceTop makes use of MacOS X's Quartz composition engine to compose the video stream with the other desktop windows and apply the relevant transparency during composition. Windows has offered support for transparent top-level windows since the release of Windows 2000 using layered windows. For more details on this support for layered windows, see the following MSDN article.

At the time that the FaceTop paper was published, I was working on a video capture and playback system for aerial surveillance work. So my plan was to see how easy it would be to implement some of the basic features of FaceTop, i.e., transparent video playback that would allow you to watch the video and still allow you to see and interact with your desktop at the same time.

Code Overview

The basic setup consists of a C# WinForms application hosting the Windows Media Player control with a couple of specific properties set on the main form and the Media Player control.

To start off the Windows Media Player, the Primary Interop Assembly needs to be installed and referenced. See this MSDN article for details on downloading and installing the Windows Media Player's PIA.

After inserting the Windows Media Player control onto the form, the following three properties need to be set on the control:

  • uiMode - None since we don't want the Media Player's controls visible, we only want to see the video stream.
  • windowlessVideo - true since we want the Media Player to use the control host's (our main form's) window and not create its own child window in which to render the video. The reason for this is that the layered windows transparency support in the OS that we're making use of only works for top-level windows and not for child windows. See the MSDN article for more details.
  • URL - source of the video. This can refer to an existing video, e.g. file:///c:/somevideo.wmv or to a video being streamed, e.g. http://somehost/.

Then the following properties need to be set on the form:

  • FormBorderStyle - None
  • Topmost - true
  • WindowState - Maximized
  • Opacity - 0.55 or whatever amount of transparency you'd like to use.

In the Form's Load event we need to add the WS_EX_TRANSPARENT extended window style to our form's window in order for input events from the mouse and keyboard to be passed through to the underlying windows.

[DllImport("user32.dll", SetLastError=true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", SetLastError=true)]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

private const int  GWL_EXSTYLE = -20;
private const int  WS_EX_TRANSPARENT = 0x20;

private void VideoPlayer_Load(object sender, System.EventArgs e)
    // Add WS_EX_TRANSPARENT style so that mouse, keyboard etc. events pass
    // thru us.
    int exstyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
    exstyle |= WS_EX_TRANSPARENT;
    SetWindowLong(this.Handle, GWL_EXSTYLE, exstyle);


The sample screenshot at the top of the article shows a live video stream being captured by a DV camera attached to my system which is then being encoded to WMV using Microsoft's Media Encoder software and then being displayed as a transparent video over the desktop using my application by pointing the Media Player to http://localhost:8080/ to pick up the video stream.

Overall there was very little effort required to enable basic transparent video playback over the desktop.


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


About the Author

Sean McLeod
Web Developer
South Africa South Africa
Software developer.

You may also be interested in...

Comments and Discussions

AnswerRe: why you havn`t used COM component? Pin
Sean McLeod15-May-06 10:35
memberSean McLeod15-May-06 10:35 
GeneralRe: why you havn`t used COM component? Pin
Ahmed.mb15-May-06 18:42
memberAhmed.mb15-May-06 18:42 
Generalbinary/exe Pin
djlippz25-Apr-06 18:44
memberdjlippz25-Apr-06 18:44 
QuestionRe: binary/exe Pin
iggzorn7-Jul-06 11:38
memberiggzorn7-Jul-06 11:38 
GeneralYou've done it Pin
jpslater12-Apr-06 21:00
memberjpslater12-Apr-06 21:00 
GeneralRe: You've done it Pin
Sean McLeod12-Apr-06 21:16
memberSean McLeod12-Apr-06 21:16 
GeneralRe: You've done it Pin
jpslater13-Apr-06 6:29
memberjpslater13-Apr-06 6:29 
GeneralRe: You've done it Pin
Sean McLeod13-Apr-06 7:08
memberSean McLeod13-Apr-06 7:08 
GeneralRe: You've done it Pin
jpslater13-Apr-06 7:20
memberjpslater13-Apr-06 7:20 
GeneralInput Video card in background my some buttons Pin
youssef25-Mar-06 11:19
memberyoussef25-Mar-06 11:19 
Generalmov codec available Pin
GraceNetwork5-Feb-06 5:20
memberGraceNetwork5-Feb-06 5:20 
GeneralRe: mov codec available Pin
Sean McLeod5-Feb-06 6:50
memberSean McLeod5-Feb-06 6:50 
Generalcommand line arguement video file Pin
GraceNetwork5-Feb-06 5:04
memberGraceNetwork5-Feb-06 5:04 
GeneralRe: command line arguement video file Pin
Sean McLeod5-Feb-06 6:47
memberSean McLeod5-Feb-06 6:47 
GeneralTransparent Desktop Video Pin
raorepalle4-Jan-06 20:10
memberraorepalle4-Jan-06 20:10 
GeneralRe: Transparent Desktop Video Pin
Sean McLeod4-Jan-06 20:20
memberSean McLeod4-Jan-06 20:20 
GeneralNeed help... Pin
relient29-Dec-05 12:53
memberrelient29-Dec-05 12:53 
GeneralRe: Need help... Pin
Sean McLeod29-Dec-05 22:36
memberSean McLeod29-Dec-05 22:36 
GeneralRe: Need help... Pin
jackyjak6-Sep-06 7:04
memberjackyjak6-Sep-06 7:04 
GeneralNicer event handling Pin
mtwilson9-Sep-05 6:35
membermtwilson9-Sep-05 6:35 
GeneralRe: Nicer event handling Pin
Sean McLeod9-Sep-05 6:56
memberSean McLeod9-Sep-05 6:56 
Generalwriting into video frame Pin
logicaldna25-Aug-05 20:37
memberlogicaldna25-Aug-05 20:37 
GeneralRe: writing into video frame Pin
Sean McLeod27-Aug-05 21:51
memberSean McLeod27-Aug-05 21:51 
QuestionHow can I compile this project by SharpDevelop Pin
Aimica20-Aug-05 4:14
memberAimica20-Aug-05 4:14 
AnswerRe: How can I compile this project by SharpDevelop Pin
Sean McLeod27-Aug-05 21:53
memberSean McLeod27-Aug-05 21:53 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.181218.1 | Last Updated 26 May 2005
Article Copyright 2005 by Sean McLeod
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid