views:

191

answers:

2

I am displaying a window using UpdateLayeredWindow and would like to add transition animations. AnimateWindow works if I use the slide or roll effects (though there is some flickering). However, when I try to use AW_BLEND to produce a fade effect, I not only lose any translucency after the animation (per-pixel and on the entire image), but a default window border also appears. Is there a way to prevent the border from appearing?

A: 

The only way I've found to successfully fade up/down a window (without the complications you're describing) is by first creating a window with the WS_EX_LAYERED extended style. I then start a timer (30ms) that gradually fades the window by calling something like:

SetLayeredWindowAttributes(0, 
                          (BYTE)(m_nAnimationCount * WINDOW_ALPHA), 
                          LWA_ALPHA);

where WINDOW_ALPHA is 23 (seems to look the best), and m_nAnimationCount is a count from 0 to 10 (or 10 to 0 if fading down).

If you discover a better way of doing this, I'd be interested to find out.

Alan
UpdateLayeredWindow and SetLayeredWindowAttributes don't really get along :-\
wkf
A: 

Since I'm using UpdateLayeredWindow, SetLayeredWindowAttributes will not work. The diagram here was pretty useful. Instead, I just need to call UpdateLayeredWindow in a loop while decreasing the SourceConstantAlpha member of the BLENDFUNCTION structure. In fact, the pointer to the BLENDFUNCTION structure, the handle to the layered window, and the flags are the only things I needed to pass into UpdateLayeredWindow if the alpha is all that is changing.

wkf