private void ShowPreview(IntPtr previewHwnd) { var mediaElementController = new PrimayScreenOnlyController(_movieManager, 1); var window = new ScreenSaverWindow(mediaElementController, 0); mediaElementController.Start(); var lpRect = new RECT(); var bGetRect = Win32API.GetClientRect(previewHwnd, ref lpRect); Debug.Assert(bGetRect); var sourceParams = new HwndSourceParameters("sourceParams") { PositionX = 0, PositionY = 0, Height = lpRect.Bottom - lpRect.Top, Width = lpRect.Right - lpRect.Left, ParentWindow = previewHwnd, WindowStyle = (int) (WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD | WindowStyles.WS_CLIPCHILDREN) }; _winWpfContent = new HwndSource(sourceParams); _winWpfContent.Disposed += (_, __) => window.Close(); _winWpfContent.RootVisual = (Visual) window.Content; UpdateManager.Instance.CheckForUpdatesAsync(); }