protected void CheckParent(object thisHandle) { IntPtr me = (IntPtr)thisHandle; while (m_onRunning) { bool isChildOfProgman = false; var progman = WinApi.FindWindow("Progman", null); WinApi.EnumChildWindows(progman, new WinApi.EnumWindowsProc((handle, lparam) => { if (handle == me) { isChildOfProgman = true; return(false); } return(true); }), IntPtr.Zero); if (isChildOfProgman == false) { lock (m_lockFlag) { m_needUpdate = true; } } m_waitHandle.WaitOne(2000); } }
public static bool FixBehindDesktopIcon(IntPtr formHandle) { IntPtr progman = WinApi.FindWindow("Progman", null); if (progman == IntPtr.Zero) { return(false); } IntPtr workerw = IntPtr.Zero; // 여러번 시도함. for (int step = 0; step < 8; ++step) { // 한번씩은 건너뜀. if (step % 2 == 0) { IntPtr result = IntPtr.Zero; WinApi.SendMessageTimeout(progman, 0x052C, new IntPtr(0), IntPtr.Zero, WinApi.SendMessageTimeoutFlags.SMTO_NORMAL, 10000, out result); } WinApi.EnumWindows(new WinApi.EnumWindowsProc((tophandle, topparamhandle) => { IntPtr p = WinApi.FindWindowEx(tophandle, IntPtr.Zero, "SHELLDLL_DefView", IntPtr.Zero); if (p != IntPtr.Zero) { workerw = WinApi.FindWindowEx(IntPtr.Zero, tophandle, "WorkerW", IntPtr.Zero); } return(true); }), IntPtr.Zero); if (workerw == IntPtr.Zero) { Thread.Sleep(1000); } else { break; } } if (workerw == IntPtr.Zero) { return(false); } WinApi.ShowWindow(workerw, 0 /*HIDE*/); WinApi.SetParent(formHandle, progman); return(true); }
public void PerformClickWallpaper(int x, int y) { IntPtr flash = this.PlayerHandle; if (flash != IntPtr.Zero) { IntPtr result = IntPtr.Zero; // 첫번째 클릭에서 포커스를 잠깐 얻고 // 두번째 클릭에서 실제로 클릭이 처리되게 하게끔 함. // TODO: 아래 방법은 개선되어야 함. for (int step = 0; step < 2; ++step) { WinApi.SendMessageTimeout(flash, 0x201 /*DOWN*/, new IntPtr(1), new IntPtr(WinApi.MakeParam(y, x)), WinApi.SendMessageTimeoutFlags.SMTO_NORMAL, 0, out result); WinApi.SendMessageTimeout(flash, 0x202 /*UP*/, new IntPtr(1), new IntPtr(WinApi.MakeParam(y, x)), WinApi.SendMessageTimeoutFlags.SMTO_NORMAL, 0, out result); } } }