Sign in to follow this  
Pc_Madness

Fade effect when changing wallpaper?

3 posts in this topic

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? :(

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

: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. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.