Claudiu
Claudiu

Reputation: 229321

windows xp: change background color programatically (how to redraw Desktop after changing registry key?)

How do I change the background/wallpaper color on Windows XP programatically? I'm changing the registry key HKEY_CURRENT_USER\Control Panel\Colors\Background (with regedit), but changing that key doesn't change the background color, although that key is changed when I change the color from the Display Properties window. Any idea why?

EDIT: ah if I change the key and reboot, the effect takes change. So how do I make it take change without rebooting?

Upvotes: 1

Views: 2662

Answers (2)

Ken White
Ken White

Reputation: 125651

You can't do it by changing the registry directly. You need to use the API function SystemParametersInfo with the SPI_SETDESKWALLPAPER flag, and also pass SPIF_SENDCHANGE as the last parameter to have the change broadcast to other applications (including the Window Manager).

BTW, changing the backgroupnd by editing the registry using RegEdit isn't "programatically".

Upvotes: 0

Blorgbeard
Blorgbeard

Reputation: 103447

I think you need to call the Windows API function SetSysColors.

Upvotes: 4

Related Questions