Strategy for creating a fadable child window

  animatewindow, c++, winapi

I’m attempting to create a window class that supports fading in and out, even for child windows. Basically it adds the WS_EX_LAYERED style to the window, and then it calls SetLayeredWindowAttributes on a timer, gradually changing the alpha value.

That approach is okay, but of course the fading will become temporarily interrupted if there are higher priority messages that come through the thread’s message queue. So, for example, if there’s some resize event going on somewhere, the fading will slow or temporarily stop.

I’m wondering if there’s a strategy to somehow avoid this. So far my only solution is to create the fadable window on its own thread, so the timer messages don’t get interrupted by anything. That solution is feasible, but it does add some additional threading complexity, so I was hoping to avoid it if possible. Thanks for any input.

Source: Windows Questions C++

LEAVE A COMMENT