• 0

Fade effect when changing wallpaper?


Question

Hey guys, I'm making a little wallpaper changer since I've finally had enough of Display Fusion's idea of 'random', and I've got it all working nicely, but the only problem is that the wallpaper changes instantly. Whenever Windows 7 or DisplayFusion rotate the wallpaper theres this lovely fade effect, which I'd love to add.

Does anyone have any idea how this is done? The best I can think of is creating multiple images each with different opacity, and then switch between them rapidly, but I doubt thats going to make my CPU very happy.

DisplayFusion has the setting "Use transitions when changing wallpaper (Windows 7 only)", which I can only assume is what I'm after, however Google is returning didly squat as to what exactly that means.

At the moment I'm using,

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, sGeneratedImagePath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);

I've tried using API monitors, but none of them can spy on DisplayFusion since its a .Net application, and they don't seem to return anything interesting when I try and spy on Windows Explorer. I've looked all over the web but I can't really see anything related to wallpapers or transitions in Window's dll files.

Anyone got any ideas? :(

Link to comment
https://www.neowin.net/forum/topic/1035559-fade-effect-when-changing-wallpaper/
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You could try using something like .NET Reflector to see how DisplayFusion does it.

This might also be of some help: http://stackoverflow...ge-in-windows-7

Edit: Just installed DisplayFusion and had a look with .NET Reflector. It's obfuscated, but it's using the IActiveDesktop interface, so I guess it does something like what was mentioned in that link.

Here's the IActiveDesktop interface for C#: http://web.archive.o...goyen/shlobj.cs

Edit2: Well, using the shlobj.cs class I linked you to, this code fades the desktop background to a new one:

IActiveDesktop iad = shlobj.GetActiveDesktop();
iad.SetWallpaper("C:\\Users\\Wolfbane\\Pictures\\Backgrounds\\2YHKN.jpg", 0);
iad.ApplyChanges(AD_Apply.ALL | AD_Apply.FORCE | AD_Apply.BUFFERED_REFRESH);

Now all you need to do is the image selection part :)

  • 0

:o! You're a champ! I looked at IActiveDesktop but MSDN said it was only for XP and below. Dirty rotten liars. :(

Woot, I snooped through the code using .Net Reflector like you suggested and I found out how to enable the transitions. :)


[DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SendMessageTimeout(
                  IntPtr hWnd,      // handle to destination window
                  uint Msg,       // message
                  IntPtr  wParam,  // first message parameter
                  IntPtr lParam,   // second message parameter
                    uint fuFlags,
                    uint uTimeout,
                    out IntPtr result

                  );
        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, IntPtr ZeroOnly);


IntPtr result = IntPtr.Zero;
SendMessageTimeout(FindWindow("Progman", IntPtr.Zero), 0x52c, IntPtr.Zero, IntPtr.Zero, 0, 500, out result);

Cheers for your help. :)

This topic is now closed to further replies.