Windows Background Changer

Programming, for all ages and all languages.
Post Reply
Kon-Tiki

Windows Background Changer

Post by Kon-Tiki »

I'm trying to make a program that changes the windows background to a random other pic in a set directory after a set amount of time has passed. There're a few things I couldn't work out though. The most prominent problem is that I don't know how to change the windows background using C++. The random-thing and the user-input for the dir and the time should be managable, but this part's too tricky for me. Anyone here know how to do that?

-Kon-Tiki-
Tim

Re:Windows Background Changer

Post by Tim »

SystemParametersInfo with SPI_SETDESKWALLPAPER will change the wallpaper with Active Desktop turned off (i.e. if you're not displaying a JPG or a GIF).
Kon-Tiki

Re:Windows Background Changer

Post by Kon-Tiki »

So png, pcx, bmp, etc work. Then I have another question: is it possible to use jpegs and gifs for that, and if it is, how do I do it? (I'm looking for maximum compatibility of wallpapers. If it's impossible, I'll stick to those formats that are possible.)

-Kon-Tiki-
Tim

Re:Windows Background Changer

Post by Tim »

No, just BMP works with SystemParametersInfo. If you want to load a JPG or GIF, you'll need to look into the Active Desktop interfaces. I don't know the answers off-hand, so you'll need to look this up in MSDN. It certainly won't be as simple as a single function call :/.
mystran

Re:Windows Background Changer

Post by mystran »

The other option ofcourse is to read the jpg/gif, and convert it to bmp, then use that. This is what old Netscape4 did, IIRC. A bit kludgy though, and not necessary any easier..
Kon-Tiki

Re:Windows Background Changer

Post by Kon-Tiki »

It seems to be exactly what Active Desktop does, but not so internal. Along with that, I think I can manage that with what Anubis showed me (showed me a dll-file along with a pdf that explains every command)

I also found a program that does the exact same thing. It's freeware and called CutePaper. It's pretty good, but only to be used until mine's done.

While trying to figure some things out yesterday, I found something that might give some trouble. When I compile in Dev-C++, it gives Dos Console App. Dunno if that's able to do this program. I know of a program I made (also a Dos Console App.) that didn't seem to work in Win2000. These things shouldn't be the case with this one, but I don't know how to make Win App. so is there a way to let Dos Console App. do this correctly without problems?

-Kon-Tiki-
anubis

Re:Windows Background Changer

Post by anubis »

Its always possible to run Windows API commands from a Dos App.

Code: Select all

#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
   MessageBox(NULL,"this","hi there",MB_OK);
   return 0;
}

the following works oin VC++ and Win 2000. Couldnot check that on Dev C++ cos it shuts down the PC during the installation only. But it should work right.

Also DLL's too work in Dos App. ;D
Kon-Tiki

Re:Windows Background Changer

Post by Kon-Tiki »

Hmmmm... Messagebox... that's about the only Win App-command I know :-\ No value-entree boxes, check boxes or things like that. Any site that sums up those and gives a brief, understandable explanation of the other commands? (My google didn't wield anything useful)

-Kon-Tiki-
Tim

Re:Windows Background Changer

Post by Tim »

I recommend the book Programming Windows by Charles Petzold. It will take you right through everything -- it's essential for any beginner in Windows programming.

You can use http://msdn.microsoft.com/library/ as a reference.
Post Reply