Click here to Skip to main content
15,860,859 members
Articles / Programming Languages / C#
Article

WallRotate - A wallpaper changer in VC#

Rate me:
Please Sign up or sign in to vote.
4.65/5 (19 votes)
17 Aug 20062 min read 66.1K   1.4K   48   18
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.

Sample image

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:

C#
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:

C#
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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Pachacutec2316-Oct-12 9:21
Pachacutec2316-Oct-12 9:21 
Bugcurrent folder problem Pin
xavierzhou4-Mar-12 23:20
xavierzhou4-Mar-12 23:20 
GeneralBug: Infinate loop on startup Pin
deathkrag28-Apr-08 7:34
deathkrag28-Apr-08 7:34 
GeneralProblem Pin
R.A.V.E.6-Aug-07 20:46
R.A.V.E.6-Aug-07 20:46 
GeneralRe: Problem Pin
R.A.V.E.7-Aug-07 13:23
R.A.V.E.7-Aug-07 13:23 
GeneralIt's cool Pin
kiquenet.com7-Feb-07 11:54
professionalkiquenet.com7-Feb-07 11:54 
GeneralNice app, but adding folders does not work Pin
DeltaEngine22-Aug-06 2:36
professionalDeltaEngine22-Aug-06 2:36 
GeneralRe: Nice app, but adding folders does not work Pin
david.price.dev22-Aug-06 5:25
david.price.dev22-Aug-06 5:25 
I was able to add my backgrounds folder without incident.

Excellent use of tooltip helps and splash screen Smile | :)
GeneralRe: Nice app, but adding folders does not work Pin
Hitesh Sharma22-Aug-06 5:50
Hitesh Sharma22-Aug-06 5:50 
GeneralRe: Nice app, but adding folders does not work Pin
DeltaEngine22-Aug-06 5:52
professionalDeltaEngine22-Aug-06 5:52 
GeneralComments Pin
Reese18-Aug-06 4:59
Reese18-Aug-06 4:59 
GeneralRe: Comments Pin
Hitesh Sharma22-Aug-06 5:46
Hitesh Sharma22-Aug-06 5:46 
GeneralNeat Pin
TerrorBite Industries17-Aug-06 18:41
TerrorBite Industries17-Aug-06 18:41 
QuestionNice... wallpapers.xml ?? Pin
rhubka17-Aug-06 12:47
professionalrhubka17-Aug-06 12:47 
AnswerRe: Nice... wallpapers.xml ?? [modified] Pin
Hitesh Sharma17-Aug-06 21:12
Hitesh Sharma17-Aug-06 21:12 
GeneralRe: Nice... wallpapers.xml ?? Pin
Alberto Venditti22-Aug-06 0:29
Alberto Venditti22-Aug-06 0:29 
GeneralRe: Nice... wallpapers.xml ?? Pin
Hitesh Sharma22-Aug-06 5:39
Hitesh Sharma22-Aug-06 5:39 
GeneralCool Pin
Ennis Ray Lynch, Jr.17-Aug-06 12:12
Ennis Ray Lynch, Jr.17-Aug-06 12:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.