Click here to Skip to main content
Click here to Skip to main content

Desktop Decorator : Changing your wallpaper the easy way in .NET

, 18 Apr 2004
Rate this:
Please Sign up or sign in to vote.
An article describing how to change the wallpaper using .NET and C#

Introduction

This small article describes how to set the desktop wallpaper. There's really not much to it. The sample application is a Windows Forms application and uses the "Wallpaper" class to set the wallpaper. The class can set wallpaper from most image sources, including images stored locally or on the network/internet. To use the sample application, run it, select an image, and click the Apply button. To test the URL loading, try selecting an image from a web-page, for example, http://hp.msn.com/global/c/lg/msft_118x35.gif

Using the code

The class for setting the desktop wallpaper is named, not surprisingly, "Wallpaper". It contains one public method name 'Set'. This takes two parameters, a URI that points to the image you want to use, and a "Style" enumeration that specifies how you want the image displayed (tiled, centered, or stretched).

public sealed class Wallpaper 
{
 ...
  public enum Style : int 
  { 
   Tiled, 
   Centered, 
   Stretched 
  } 

  public static void Set ( Uri uri, Style style ) 
  {
    ...
  } 
}

Points of Interest

The class first saves your image to a temporary file using a Windows Bitmap format. This allows you to pass other image formats, such as a gif and jpeg files and have them automatically converted and used as wallpaper images. The class also allows source images from almost any location. A URI is passed which describes where the image is located. Feel free to use this code however you please. The usual stuff: if it buggers up your machine/life etc. then it's not my fault!

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

Share

About the Author

Steve Dunn
Web Developer
United States United States
I was born at a very young age. My hobbies include reading pornography and killing squirrels.

Comments and Discussions

 
GeneralMy vote of 1 PinmemberMember 1003638211-Dec-13 0:18 
Generalhi Pinmembersandeepparekh2-Jun-11 21:26 
QuestionHow change html file to wallpaper? PinmemberDimaNikolaevich7-Aug-06 7:18 
Questionhow can i get current wallpaper,not use regedit info? Pinmemberargoli19-Mar-05 16:02 
GeneralA little sugestion with Centered Pinmemberwhitesnake6-Feb-05 16:54 
GeneralProxies and thanks PinsitebuilderPaul Watson20-Aug-04 7:53 
GeneralRestore original wallpaper PinmemberAntonio Barros22-Apr-04 4:24 
GeneralRe: Restore original wallpaper PinmemberS0k4r13-Dec-04 23:53 
GeneralI looked at this method too PinmemberNathan Blomquist19-Apr-04 6:05 
GeneralRe: I looked at this method too PinmemberJason Henderson20-Apr-04 3:33 
GeneralRe: I looked at this method too PinmemberNathan Blomquist20-Apr-04 5:17 
GeneralGood Hobbies PinmemberNorm Almond19-Apr-04 1:59 
GeneralRe: Good Hobbies PinmemberUncle Monkey19-Apr-04 2:50 
GeneralRe: Good Hobbies Pinmemberhxxbin23-Apr-04 4:59 
Now I need a .net theme changer Poke tongue | ;-P
 
----
hxxbin

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141030.1 | Last Updated 19 Apr 2004
Article Copyright 2004 by Steve Dunn
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid