private void PreviewWallpaper_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (_InProgressClosing) { e.Cancel = true; return; } //..detach wp window from this dialogue. SetupDesktop.SetParentSafe(processHWND, IntPtr.Zero); }
private void PreviewWallpaper_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (_InProgressClosing) { e.Cancel = true; return; } System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { App.w.LoadWallpaperFromWpDataFolder(); })); //..detach wp window from this dialogue. SetupDesktop.SetParentSafe(processHWND, IntPtr.Zero); }
/// <summary> /// makes program child of window ui framework element. /// </summary> /// <param name="window"></param> /// <param name="pgmHandle"></param> /// <param name="element"></param> public static void SetProgramToFramework(Window window, IntPtr pgmHandle, FrameworkElement element) { IntPtr previewHwnd = new WindowInteropHelper(window).Handle; NativeMethods.RECT prct = new NativeMethods.RECT(); var reviewPanel = WindowOperations.GetAbsolutePlacement(element, true); if (!NativeMethods.SetWindowPos(pgmHandle, 1, (int)reviewPanel.Left, (int)reviewPanel.Top, (int)reviewPanel.Width, (int)reviewPanel.Height, 0 | 0x0010)) { SetupDesktop.LogWin32Error("setwindowpos(1) fail MapWallpaperToWindow(),"); } //ScreentoClient is no longer used, this supports windows mirrored mode also, calculate new relative position of window w.r.t parent. NativeMethods.MapWindowPoints(pgmHandle, previewHwnd, ref prct, 2); SetupDesktop.SetParentSafe(pgmHandle, previewHwnd); //Position the wp window relative to the new parent window(workerw). if (!NativeMethods.SetWindowPos(pgmHandle, 1, prct.Left, prct.Top, (int)reviewPanel.Width, (int)reviewPanel.Height, 0 | 0x0010)) { SetupDesktop.LogWin32Error("setwindowpos(2) fail MapWallpaperToWindow(),"); } }