How do I suppress the default animation that occurs when I hide or show a window?

Raymond Chen

A customer wanted to know how they can disable the default fade-in/fade-out animation that occurs when a window is hidden or shown. “I don’t want to use WS_EX_TOOL­WINDOW because that causes my window to disappear from the taskbar. I tried Dwm­Enable­Composition but that affects the entire desktop and is too jarring. We want to suppress the effect because our program replaces one window with another, and we want the operation to be invisible to the user.”

Whoa, heading straight for Dwm­Enable­Composition? That’s using a global solution to a local problem.

To disable the animations on a specific window, use something like this:

HRESULT DisableDwmAnimations(HWND hwnd)
    BOOL fDisable = TRUE;
    return DwmSetWindowAttribute(hwnd,

Re-enabling the animations is left as an exercise for the reader.


Discussion is closed.

Feedback usabilla icon