Sticky wallpaper!

This is a discussion on Sticky wallpaper! within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I've now tried three methods to get the wallpaper on my desktop to change:- Code: (Method 1) DWORD dwRet; ...

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,259

    Angry Sticky wallpaper!

    Hello,

    I've now tried three methods to get the wallpaper on my desktop to change:-
    Code:
    (Method 1)
    DWORD dwRet;
    
    dwRet = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Image1.bmp", SPIF_SENDCHANGE); //returns 0 (GetLastError returns 0?!?)
    
    (Method 2)
    HKEY hKey;
    
    RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_SET_VALUE, &hKey);
    RegSetValueEx(hKey, "Wallpaper", 0, REG_SZ, "C:\\Image1.bmp", 14);
    RegCloseKey(hKey);
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Wallpaper", SMTO_NORMAL, 5, NULL);
    
    (Method 3)
    WriteProfileString("Desktop", "Wallpaper", "C:\\Image1.bmp");
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Wallpaper", SMTO_NORMAL, 5, NULL);
    With the first method, nothing happens at all. With the second method, the entry in Display Properties changes, but the desktop doesn't change. With the third method, the entry in WIN.INI changes, but the desktop doesn't change. Everyone seems to be able to use the first method just fine, but for some reason I can't get any of these methods to work properly!
    Last edited by SMurf; 02-20-2003 at 12:15 PM.

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,259
    Well I managed to get the second method working properly by sending "SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);" after changing the wallpaper in the registry!

    I'm still curious as to why I can't just use a single SPI call, though...

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    <Yoda Voice>
    "Com you must use"
    </Yoda Voice>

    http://www.cprogramming.com/cboard/s...ight=wallpaper

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,259

    Exclamation

    Noooo! Must... resist... non-pure C methodology...

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by SMurf
    Noooo! Must... resist... non-pure C methodology...
    "Strong is the dark side!"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desktop Wallpaper - Animated Tiff
    By Rune Hunter in forum C# Programming
    Replies: 3
    Last Post: 02-08-2008, 05:59 PM
  2. Wallpaper Woes
    By TheSquid in forum Windows Programming
    Replies: 6
    Last Post: 12-21-2004, 01:13 PM
  3. wallpaper problem ....
    By goran in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 12-21-2001, 07:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21