Introduction
One day, looking at my dull desktop gave me the inspiration of writing a program which would periodically change the wallpaper. The idea sounded cool to me, and I decided to start this project in Visual C# as it would also help me learn more about the .NET Framework.
WallRotate is a simple-to-use software that will give your boring desktop new colours in a few minutes. WallRotate manages your wallpapers, and changes them periodically.
Some features of WallRotate:
- Supports many popular image formats (BMP, JPG, GIF, PNG, and many more)
- User-friendly interface
- Creates a list of your favourite wallpapers and customizes them
- You can change the wallpaper after a set interval
- Gives you a clear preview of the wallpaper, WYSIWYG
- Changes wallpapers when Windows starts
- Sets different positions for different wallpapers (center, tile, stretch)
- Sets background colour for wallpapers
- Plays sound clips when wallpaper changes
- Hotkeys to easily change the wallpaper
- System tray icon for easy access
How it works?
Below, I present some ideas on how WallRotate works.
Changing wallpapers:
There is a Windows API by the name of SystemParametersInfo
, which sets system level wide parameters. With the first parameter as SPI_SETDESKWALLPAPER
, we can change the wallpaper by passing the path of the image as the other parameter.
To use SystemParametersInfo
, I had to invoke it from my .NET application. Shown below is the declaration for it:
const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int SystemParametersInfo (int uAction,
int uParam,
string lpvParam,
int fuWinIni);
Now, to change the wallpaper, all I had to do was:
SystemParametersInfo (SPI_SETDESKWALLPAPER, 0, strWallpaperPath,
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
Storing and maintaining the list of wallpapers:
To store the list of wallpapers, I used XML. When the program loads, it looks for a file wallpapers.xml in the current directory and loads the list from it.
Loading, saving, and resizing images:
Playing with images is easy in the .NET Framework. The Image
class took care of most of my needs.
Conclusion
I’m a .NET virgin, so please excuse me for the mistakes you see in the program, and kindly let me know about them. Same goes for any bugs found.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.