CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2001
    Posts
    31

    how to code to change wallpaper?

    how to code to change wallpaper?


  2. #2
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: how to code to change wallpaper?

    http://www.codeguru.com/cgi-bin/bbs/...age=0&Limit=25

    Please - rate answer if it helped you
    It gives me inspiration when I see myself in the top list =)

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    [email protected] | ICQ:57404554 | http://soukhov.com

    Member of Russian Software Developers Network http://rsdn.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

  3. #3
    Join Date
    Mar 2001
    Location
    Singapore
    Posts
    57

    Re: how to code to change wallpaper?

    HI, this is what i did:

    #define CAPS_WALLPAPER_BESTFIT 0
    #define CAPS_WALLPAPER_STRETCH 1
    #define CAPS_WALLPAPER_TILE 2

    void CMainFrame::SetWallPaper ( int Style )
    {
    // Get window path and save image to the directory
    char* Filepath = _T("C:\\Winnt\\ACD Wallpaper.bmp");

    // Prepare the entry value
    BYTE TileFlag[2] = {'0',0};
    BYTE StyleFlag[2] = {'0',0};

    if ( Style == CAPS_WALLPAPER_STRETCH )
    StyleFlag[0] = '2';
    if ( Style == CAPS_WALLPAPER_TILE )
    TileFlag[0] = '1';

    // Set the Wall Paper now
    HKEY hKey;
    if ( RegOpenKeyEx (HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_ALL_ACCESS, &hKey)
    == ERROR_SUCCESS )
    {
    LPCSTR EntryPath = "Wallpaper";
    LPCSTR EntryTile = "TileWallpaper";
    LPCSTR EntryStyle = "WallpaperStyle";

    RegSetValueEx (hKey, EntryTile, 0, REG_SZ, TileFlag, 1);
    RegSetValueEx (hKey, EntryStyle, 0, REG_SZ, StyleFlag, 1);
    SystemParametersInfo (SPI_SETDESKWALLPAPER, 0, Filepath, SPIF_UPDATEINIFILE|SPIF_SENDWININICHANGE);

    RegFlushKey (hKey);
    RegCloseKey (hKey);
    }
    }

    void CMainFrame::OnSetWallPaperBestFit()
    {
    SetWallPaper (CAPS_WALLPAPER_BESTFIT);
    }

    void CMainFrame::OnSetWallPaperStretch()
    {
    SetWallPaper (CAPS_WALLPAPER_STRETCH);
    }

    void CMainFrame::OnSetWallPaperTile()
    {
    SetWallPaper (CAPS_WALLPAPER_TILE);
    }


  4. #4
    Join Date
    Jun 1999
    Location
    Singapore
    Posts
    1,304

    Re: how to code to change wallpaper?

    http://codeguru.earthweb.com/cgi-bin...age=0&Limit=25

    Chen Weiye
    ------------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life...
    ------------------------------------------------------------------------------
    Chen Weiye
    -----------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life
    -----------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured