Click here to Skip to main content
Licence 
First Posted 17 Aug 2006
Views 37,443
Bookmarked 47 times

WallRotate - A wallpaper changer in VC#

By | 17 Aug 2006 | Article
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:

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.

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

About the Author

Hitesh Sharma



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Bugcurrent folder problem Pinmemberxavierzhou23:20 4 Mar '12  
GeneralBug: Infinate loop on startup Pinmemberdeathkrag7:34 28 Apr '08  
GeneralProblem PinmemberR.A.V.E.20:46 6 Aug '07  
GeneralRe: Problem PinmemberR.A.V.E.13:23 7 Aug '07  
GeneralIt's cool Pinmemberalhambra-eidos11:54 7 Feb '07  
GeneralNice app, but adding folders does not work PinmemberexDreamDuck2:36 22 Aug '06  
GeneralRe: Nice app, but adding folders does not work Pinmemberpric01125:25 22 Aug '06  
GeneralRe: Nice app, but adding folders does not work Pinmemberhitesh_sharma5:50 22 Aug '06  
GeneralRe: Nice app, but adding folders does not work PinmemberexDreamDuck5:52 22 Aug '06  
GeneralComments PinmemberReese4:59 18 Aug '06  
GeneralRe: Comments Pinmemberhitesh_sharma5:46 22 Aug '06  
GeneralNeat PinmemberTerrorBite Industries18:41 17 Aug '06  
QuestionNice... wallpapers.xml ?? Pinmemberrhubka12:47 17 Aug '06  
AnswerRe: Nice... wallpapers.xml ?? [modified] Pinmemberhitesh_sharma21:12 17 Aug '06  
GeneralRe: Nice... wallpapers.xml ?? PinmemberAlberto Venditti0:29 22 Aug '06  
GeneralRe: Nice... wallpapers.xml ?? Pinmemberhitesh_sharma5:39 22 Aug '06  
GeneralCool PinmemberEnnis Ray Lynch, Jr.12:12 17 Aug '06  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 17 Aug 2006
Article Copyright 2006 by Hitesh Sharma
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid