0

When min/maximizing windows on Windows, DWM applies the transition effect so the window gradually resizes, changes its transparency and moves. I want to mimic this effect on thumbnails, so I want to know the animation algorithm and its parameters (duration, transparency and size/position change step, etc.).

n0p
  • 713
  • 10
  • 23
  • 1
    I don't think it's "documented" per se. You can reuse some of this: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-animatewindow – Simon Mourier Mar 28 '22 at 12:36
  • Unfortunately, it is not possible to use AnimateWindow() function on thumbnails as it is only for windows. Also, the animation itself doesn't seem to fire EVENT_OBJECT_LOCATIONCHANGE. – n0p Mar 28 '22 at 14:34

1 Answers1

1

These kind of graphical animations are rarely documented, just because it's quite usual to be allowed to disable them first, and sometimes, they adapt themselves to hardware's capabilities and/or theme. It's not really an "algorithm" per se but rather a cosmetic thingy.

So your best shot is to implement quite the same, BUT with a bunch load of parameters - each time you need a constant, you set it as a parameter within a global structure that contains them all.

You resize first the window?

  • Parameterize the number of steps.
  • Parameterize the delay between each step.
  • If window moves, set the same steps/delay parameterization for each axis.

Then you change transparency?

  • Get current transparency, set number of steps and delay.
  • Parameterize the final transparency.
  • What if current transparency is lower than final transparency?

Then moving window:

  • Which final speed do you want? A parameter for that.
  • Minimum/maximum number of steps.
  • Where is window supposed to move to? Another (X,Y) parameter.

Want to do the three simultaneously?

  • Add one or two parameters to do some effects simultaneously, or sequentially.
  • To achieve that, you'll need some helper functions to "get next step" for each implemented effet, so that you can do them simultaneously easily by calling (or not calling!) each individual "next step" within your loop.

And so on...

After that, you just have to try it several times, and adjust your parameters accordingly. Obviously, having a little GUI allowing you to do it in real time without recompiling your code is better and easier.

Wisblade
  • 1,483
  • 4
  • 13
  • Thanks for the input. This would be a kind of "brute force" approach which I'd like to avoid. Reverse engineering AnimateWindow() will be a better option I guess, but time consuming. – n0p Mar 28 '22 at 14:36
  • 1
    @n0p You can do this only when you have access to source code... And sometimes, even with source code, it can be extremely hard to understand how such an animation really work: it can use lot of subroutines and/or tricks, or be too "melted" into other code to be reusable. It's not really brute force, it's quite simple to do and, more important, it allows you to make an adaptative code (i.e. being able to disable SOME parts but not the others, according to current machine / OS / GPU). It's great for end-user comfort. – Wisblade Mar 28 '22 at 14:40