public void ToWallerpaperWindow(NativeWindowModel window) { if (!window.IsHasProcessExits()) { //最大化启动的程序 User32Window.ShowWindow(window.Handle, (short)User32Window.Cmd_SHOWWINDOWS.SW_RESTORE); IntPtr progman = User32Window.FindWindow("Progman", null); IntPtr result = User32Window.SendMessage(progman, 0x052C, new IntPtr(0), IntPtr.Zero); IntPtr workerw = IntPtr.Zero; User32Window.EnumWindows(((tophandle, topparamhandle) => { IntPtr p = User32Window.FindWindowEx(tophandle, IntPtr.Zero, "SHELLDLL_DefView", null); if (p != IntPtr.Zero) { workerw = User32Window.FindWindowEx(IntPtr.Zero, tophandle, "WorkerW", null); } return(true); }), IntPtr.Zero); SetParentWindow(window.Handle, workerw); int p1 = User32Window.GetWindowLongA(window.Handle, (int)WindowLongFlags.GWL_STYLE); p1 &= ~13500416; User32Window.SetWindowLong(window.Handle, (int)WindowLongFlags.GWL_STYLE, p1); //最大化启动的程序 User32Window.ShowWindow(window.Handle, (short)User32Window.Cmd_SHOWWINDOWS.SW_MAXIMIZE); //User32Window.MoveWindow(window.Handle, 0, 0, Screen.AllScreens[0].WorkingArea.Width, // Screen.AllScreens[0].WorkingArea.Height, false); User32Window.SetActiveWindow(window.Handle); } }
/// <summary> /// 激活窗口并置顶 /// </summary> /// <param name="window"></param> public void SetActiveWindow(NativeWindowModel window) { User32Window.SetActiveWindow(window.Handle); User32Window.SetForegroundWindow(window.Handle); }