Skip to content

Commit

Permalink
Send WM_SETTINGCHANGE to refresh the desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Jan 12, 2025
1 parent 7e18ee0 commit 99c9884
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/WallpaperApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public static void EnableTransitions()
SendMessageTimeout(FindWindow("Progman", null), 0x52c, IntPtr.Zero, IntPtr.Zero, 0, 500, out result);
}

public static void RefreshDesktop()
{
IntPtr result = IntPtr.Zero;
SendMessageTimeout(FindWindow("Progman", null), 0x001a, IntPtr.Zero, IntPtr.Zero, 0, 500, out result);
}

public static void SetWallpaper(string imagePath, int displayIndex = -1)
{
EnableTransitions();
Expand All @@ -49,6 +55,8 @@ public static void SetWallpaper(string imagePath, int displayIndex = -1)
thread.Start();
thread.Join(2000);
}

RefreshDesktop(); // Send WM_SETTINGCHANGE to refresh the desktop
}
}
}

0 comments on commit 99c9884

Please sign in to comment.