Jump to content
  • Advertisement
Sign in to follow this  
KuroKitten

can you change the background?

This topic is 4623 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible, using win32, to change the desktop background to a different image? I'm trying to make a simple desktop changing program, and havn't been able to find a command that can do this. I'm wondering if there even is one (it seems like something rather complicated, so i wouldn't be surprised) Thanks^^ Meow.

Share this post


Link to post
Share on other sites
Advertisement
i've tried both functions, and with both i get errors that I'm unsure how to fix...

With SystemParametersInfo() The only error i get is with the value that i designate the image to be set as the wallpaper. this is how I have the function called:

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\mountain.bmp", SPIF_UPDATEINIFILE);


Now, with the IActiveDesktop::SetWallpaper() I get a whole slew of errors. My guess is there's a header I need to include?

Again, thanks for any help^^

Mreow.

Edit: I figured out the compiling error, i had to point to the adress of a string, not include a direct string. Now, however, my issue is that the background jsut gets set to black... I'm 100% possitive the file exists...

here is what i have now:

string BackImage = "C:\\Main\\Desktop\\GiftsUngiven.jpg";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &BackImage, SPIF_UPDATEINIFILE);

Share this post


Link to post
Share on other sites
This is totally from the hip, but if this is the win32 api, you'll probably want a pointer to a C-String rather than an std::string.

Share this post


Link to post
Share on other sites
changing &BackImage to BackImage.c_str() pops the same error as leaving it alone...


string BackImage = "C:\\Main\\Desktop\\GiftsUngiven.jpg";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, BackImage.c_str(), SPIF_UPDATEINIFILE);


I'm looking into CStings aswell.

Mreow.

Share this post


Link to post
Share on other sites
You might have to cast your char* to a void* because that is what it expects.
so...

string BackImage = "C:\\Main\\Desktop\\GiftsUngiven.jpg";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)BackImage.c_str(), SPIF_UPDATEINIFILE);

also, I think your image has to be a BMP, unless you have Active Desktop enabled. A jpg might result in a blank background being used.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!