/// <summary> /// 设置缩略图到指定窗口句柄 /// </summary> public IntPtr SetDesktopBackgroundToWindow(IntPtr dest, int width, int height) { //backgroundPath = null; //IntPtr wep = IntPtr.Zero; //User32Window.EnumWindows(((hwnd, e) => //{ // IntPtr p = User32Window.FindWindowEx(hwnd, // IntPtr.Zero, // "SHELLDLL_DefView", // null); // if (p != IntPtr.Zero) // { // IntPtr workerw = User32Window.FindWindowEx(IntPtr.Zero, // hwnd, // "WorkerW", // null); // User32Window.EnumChildWindows(workerw, ((hwnd2, e2) => // { // wep = hwnd2; // return true; // }), IntPtr.Zero); // } // return true; //}), IntPtr.Zero); //if (wep == IntPtr.Zero) //{ // IntPtr r = IntPtr.Zero; // MouseHook.SystemParametersInfo((uint)MouseHook.SystemParametersDesktopInfo.SPI_GETDESKWALLPAPER, 300, r, (uint)MouseHook.SystemParamtersInfoFlags.None); // backgroundPath = Marshal.PtrToStringAuto(r); //默认桌面路径 // return; //} //User32Window.SetWindowPos(dest, HWND_BOTTOM, 0, 0, 0, 0, // SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_SHOWWINDOW); IntPtr p = User32Window.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null); ReleaseBackground(dest); var temp = DWMApi.DwmRegisterThumbnail(dest, p, out dest); if (temp == 0) { BackgroundUpdate(dest, width, height); } return(dest); }
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); } }