Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Hell-Lord on October 05, 2007, 02:46 AM

Title: Changing desktop wallpaper
Post by: Hell-Lord on October 05, 2007, 02:46 AM
Anyone aware of any good methods at doing this? I was thinking of using SetWallpaper or the SystemParametersInfo API. Is there an other suitable way?

Edit: Just to note i also have to set the picture display to either Tile, Stretch or Center.
Title: Re: Changing desktop wallpaper
Post by: Barabajagal on October 05, 2007, 03:10 AM
SystemParametersInfo is the way I've always done it. However, for total control, use the registry. "HKEY_CURRENT_USER\Control Panel\Desktop" has 3 important keys for you: Wallpaper, TileWallpaper, and WallpaperStyle. Experiment with them and you'll get the hang of what they do.
Title: Re: Changing desktop wallpaper
Post by: Hell-Lord on October 05, 2007, 03:17 AM
Thanks ill mess about and see how far i get :)
Title: Re: Changing desktop wallpaper
Post by: Hell-Lord on October 05, 2007, 04:45 AM
Any reason why it would be better to use the SystemParametersInfo instead of the IActiveDesktop class?
Title: Re: Changing desktop wallpaper
Post by: Camel on October 05, 2007, 09:29 AM
Just guessting, but IActiveDesktop sounds like it requires active desktop, which you should avoid like the plague.
Title: Re: Changing desktop wallpaper
Post by: brew on October 05, 2007, 09:55 PM
SystemParametersInfo seems to only accept bitmap files for desktop wallpapers. Windows desktop supports other file types too (.jpg, .gif, .png, etc) so how would I be able to make a non-bitmap image file my desktop background?
Title: Re: Changing desktop wallpaper
Post by: Barabajagal on October 05, 2007, 10:00 PM
Editing the registry, like I said.
Title: Re: Changing desktop wallpaper
Post by: brew on October 05, 2007, 10:34 PM
After closer inspection of that registry directory i have found the registry keys named "ConvertedWallpaper" and "Converted Wallpaper Last WriteTime" (a string and an 8 byte FILETIME, respectively) suggesting that the wallpaper can not be anything but a .bmp file, and anything else is converted and written to a temporary bitmap. I guess I've answered my own question.
Moral of the story: A desktop wallpaper changer is much more time-consuming and involved then it seems at first, unless it's abilities are going to be very limited (bitmap files only).
Title: Re: Changing desktop wallpaper
Post by: Joe[x86] on October 06, 2007, 02:36 AM
Quote from: brew on October 05, 2007, 10:34 PM
After closer inspection of that registry directory i have found the registry keys named "ConvertedWallpaper" and "Converted Wallpaper Last WriteTime" (a string and an 8 byte FILETIME, respectively) suggesting that the wallpaper can not be anything but a .bmp file, and anything else is converted and written to a temporary bitmap. I guess I've answered my own question.
Moral of the story: A desktop wallpaper changer is much more time-consuming and involved then it seems at first, unless it's abilities are going to be very limited (bitmap files only).

I'm rather confident that the API would include a JPEG to Bitmap converter, then, if Windows uses one. If not, download a DLL from somewhere. You *know* that someone has written one. :P
Title: Re: Changing desktop wallpaper
Post by: Barabajagal on October 06, 2007, 04:12 PM
ijl11.dll is an excellent JPEG conversion DLL. I use it for a Webcam application I'm working on (which allows you to control the JPEG quality and framerate [1 to 25 FPS] of the stream you send). You can get it from http://vbaccelerator.com/ , though it works with any language.
Title: Re: Changing desktop wallpaper
Post by: brew on October 06, 2007, 04:37 PM
I'm thinking that the function windows uses to convert other file formats to BMP is within the dll used by Windows Fax and Picture Viewer, does anyone know the filename of this dll?
Title: Re: Changing desktop wallpaper
Post by: Camel on October 07, 2007, 03:06 AM
Quote from: Andy on October 06, 2007, 04:12 PM
ijl11.dll is an excellent JPEG conversion DLL. I use it for a Webcam application I'm working on (which allows you to control the JPEG quality and framerate [1 to 25 FPS] of the stream you send). You can get it from http://vbaccelerator.com/ , though it works with any language.

I bet it doesn't have JNI exports to work with Java!
Title: Re: Changing desktop wallpaper
Post by: Warrior on October 07, 2007, 07:20 AM
And C# has native support for converting images.
Title: Re: Changing desktop wallpaper
Post by: Banana fanna fo fanna on October 08, 2007, 12:11 AM
Quote from: Warrior on October 07, 2007, 07:20 AM
And C# has native support for converting images.

jesus christ will you cool it? it's in the c/c++ programming forum for a reason.
Title: Re: Changing desktop wallpaper
Post by: Warrior on October 08, 2007, 02:52 AM
Quote from: Banana fanna fo fanna on October 08, 2007, 12:11 AM
Quote from: Warrior on October 07, 2007, 07:20 AM
And C# has native support for converting images.

jesus christ will you cool it? it's in the c/c++ programming forum for a reason.

^ lol.
/me points to the Java mention in this thread too

I know you like me and all, but try not to be a stalker.
Title: Re: Changing desktop wallpaper
Post by: Banana fanna fo fanna on October 08, 2007, 01:17 PM
Quote from: Warrior on October 08, 2007, 02:52 AM
Quote from: Banana fanna fo fanna on October 08, 2007, 12:11 AM
Quote from: Warrior on October 07, 2007, 07:20 AM
And C# has native support for converting images.

jesus christ will you cool it? it's in the c/c++ programming forum for a reason.

^ lol.
/me points to the Java mention in this thread too

I know you like me and all, but try not to be a stalker.

I think me and you lurk in the same threads; I wasn't actually stalking you...

You and I are similar methinks.
Title: Re: Changing desktop wallpaper
Post by: Chriso on October 14, 2007, 07:19 AM
Convenient excuse for stalking  :P
Title: Re: Changing desktop wallpaper
Post by: Banana fanna fo fanna on October 14, 2007, 07:32 PM
Nah I was lurking this thread before. I don't have much win32 api experience, though, so I like picking up tidbits here and there.