Click here to Skip to main content
14,487,386 members

Transparent Desktop Video

Rate this:
4.46 (15 votes)
Please Sign up or sign in to vote.
4.46 (15 votes)
26 May 2005
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.

Comments and Discussions

QuestionCompile error: The type or namespace name "AxMicrosoft" could not be found. Pin
forumarbeit25-Feb-18 6:23
Memberforumarbeit25-Feb-18 6:23 
QuestionThanks Pin
kkoukakis15-Sep-12 22:12
Memberkkoukakis15-Sep-12 22:12 
PraiseMessage Closed Pin
31-May-16 0:59
Memberpixelup_sk31-May-16 0:59 
GeneralThanks Pin
MarkJoel6029-Mar-10 4:22
MemberMarkJoel6029-Mar-10 4:22 
GeneralHi Guys Pin
dansaliveagain9-Feb-10 18:49
Memberdansaliveagain9-Feb-10 18:49 
Generalen... Pin
josmoi29-Apr-09 20:43
Memberjosmoi29-Apr-09 20:43 
QuestionWorking on VS 2005 / 2008? Pin
myspaceebay0014-Dec-08 12:43
Membermyspaceebay0014-Dec-08 12:43 
GeneralDual Monitors Pin
Pravinc198410-Sep-08 6:03
MemberPravinc198410-Sep-08 6:03 
Generali have error Pin
webshot8-Aug-08 7:53
Memberwebshot8-Aug-08 7:53 
GeneralActivex problem Pin
myceng21-Aug-07 22:21
Membermyceng21-Aug-07 22:21 
GeneralRe: Activex problem Pin
myspaceebay0014-Dec-08 11:45
Membermyspaceebay0014-Dec-08 11:45 
Questionproblems with transfer to a different computer Pin
nomism4-Nov-06 4:56
Membernomism4-Nov-06 4:56 
AnswerRe: problems with transfer to a different computer Pin
Sean McLeod6-Nov-06 5:11
MemberSean McLeod6-Nov-06 5:11 
GeneralRe: problems with transfer to a different computer Pin
nomism4-Dec-06 22:46
Membernomism4-Dec-06 22:46 
QuestionSound But No Video Pin
centrex8j12-Oct-06 21:34
Membercentrex8j12-Oct-06 21:34 
AnswerRe: Sound But No Video Pin
Zaraken25-Mar-07 12:52
MemberZaraken25-Mar-07 12:52 
GeneralLive video lags Pin
jackyjak6-Sep-06 23:19
Memberjackyjak6-Sep-06 23:19 
GeneralRe: Live video lags Pin
Sean McLeod7-Sep-06 3:22
MemberSean McLeod7-Sep-06 3:22 
QuestionOther Video Formats [modified] Pin
Peter_Bate21-May-06 20:29
MemberPeter_Bate21-May-06 20:29 
AnswerRe: Other Video Formats [modified] Pin
Sean McLeod22-May-06 0:57
MemberSean McLeod22-May-06 0:57 
GeneralRe: Other Video Formats [modified] Pin
Peter_Bate30-May-06 20:51
MemberPeter_Bate30-May-06 20:51 
GeneralRe: Other Video Formats [modified] Pin
Sean McLeod30-May-06 22:59
MemberSean McLeod30-May-06 22:59 
GeneralRe: Other Video Formats [modified] Pin
Peter_Bate8-Jun-06 14:50
MemberPeter_Bate8-Jun-06 14:50 
GeneralRe: Other Video Formats Pin
KienNT7825-May-08 18:43
MemberKienNT7825-May-08 18:43 
Questionwhy you havn`t used COM component? Pin
Ahmed.mb15-May-06 9:30
MemberAhmed.mb15-May-06 9:30 

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.

Posted 26 May 2005


145 bookmarked