private void Form1_Paint(object sender, PaintEventArgs e) { if (timeout == 0) { IntPtr desktop = Win32Functions.GetDC(IntPtr.Zero); using (Graphics g = Graphics.FromHdc(desktop)) { g.FillRectangle(Brushes.Transparent, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); } Win32Functions.ReleaseDC(IntPtr.Zero, desktop); } else { base.OnPaint(e); } }
public static IntPtr GetDTHandle() { IntPtr hDesktopWin = Win32Functions.GetDesktopWindow(); IntPtr hProgman = Win32Functions.FindWindow("Progman", "Program Manager"); IntPtr hWorkerW = IntPtr.Zero; IntPtr hShellViewWin = Win32Functions.FindWindowEx(hProgman, IntPtr.Zero, "SHELLDLL_DefView", ""); if (hShellViewWin == IntPtr.Zero) { do { hWorkerW = Win32Functions.FindWindowEx(hDesktopWin, hWorkerW, "WorkerW", ""); hShellViewWin = Win32Functions.FindWindowEx(hWorkerW, IntPtr.Zero, "SHELLDLL_DefView", ""); } while (hShellViewWin == IntPtr.Zero && hWorkerW != null); } return(hShellViewWin); }
public static void ToggleDesktopIcons() { Win32Functions.SendMessage(GetDTHandle(), 0x0111, (IntPtr)0x7402, (IntPtr)0); }