views:

94

answers:

1

I'm writing a C# WPF application that creates a video capture of the active window. What I want to do is overlay a transparent .png file in the corner of the active window while a capture is in progress so that all the videos created by my application are watermarked.

If I have the IntPntr handle of the window I am capturing and an image file - what is the best way to go about this?

Thanks

A: 

Construct a new HwndSource, passing the IntPtr handle of the parent:

var hwndSource = new HwndSource(new HwndSourceParameters("OverlayWindow")
{
  ParentWindow = parentHandleIntPtr,
  UsesPerPixelOpacity = true,
  Width = 100,
  Height = 100,
})
{
  RootVisual = new Image { Source = watermarkBitmapSource },
};

If this doesn't work right away, test your "new Image ..." code in a regular WPF window to make sure it works. If you still aren't seeing anything, try presenting something like a CheckBox or TextBlock using HwndSource to make sure that works, then put them together.

Ray Burns