There are few ways... You can e.g. split your GIF into frames and fill with them an image list which you'll assign to the VT. Then, having a timer you with each tick (`OnTimer` event) trigger the node to repaint (`InvalidateNode` method) and in the VT's `OnGetImageIndex` you assign the currently played frame index to the `ImageIndex` parameter. @Antonio, yes. And how about PHP ? Do the people still use it ?
– TLamaMay 11 '14 at 14:14
@TLama, no this isn't perfect solution.... works but wrong and too slower, see: http://images.vfl.ru/ii/1399826407/2208fb6b/5101161.gif original gif: http://images.vfl.ru/ii/1399826487/7df8abeb/5101180.gif Any other solutions?
– AlexLLMay 11 '14 at 16:41
Good to know :-) I mentioned that as one of the possible options... But anyway, the speed of the animation you can increase by decreasing the timer's interval (e.g. to 50). And using a [`code like this`](http://pastebin.com/jj802utP) should work for your 12 frame GIF image (assuming you have filled all the frames in the image list linked through the `Images` property of your VT).
– TLamaMay 11 '14 at 17:11
I forgot to mention; there is no built-in way to animate images inside the nodes, so using a timer that will force the node(s) to repaint is necessary. What can differ is the way what and how to draw... The way I've suggested is easy and quite straightforward. However, more complicated your task become when your GIF frames use variable timing.
– TLamaMay 11 '14 at 19:10
@TLama, perfect solution! But when I do mouse over on the node, animation speedup at each mouse movement. Any ideas, how to fix that?
– AlexLLMay 11 '14 at 20:32
1
I couldn't notice that, but you need to be aware that timer itself is inaccurate and that input messages (like mouse movement) are processed before the timer's tick `WM_TIMER` message. You can correct the visual inaccuracy by knowing the timer's tick delay. If you store a tick count (obtained by the `GetTickCount` function) with each timer tick, you can then calculate how long it took till the next tick. By this value you can then skip certain frames to keep your animation visually smooth.
– TLamaMay 11 '14 at 21:00
I use [code like this](http://pastebin.com/vyhMaXcj) for this purpose: Put the frames in an imagelist, Calculate the frame based on Windows tick count an trigger a repaint after the animation interval. TDelayedProcedure derives from a task or workitem which can be added to a thread-pool. You can use a thread-pool as it is included in [Omni ThreadLibrary](http://www.omnithreadlibrary.com) or [ShellBrowser Components](http://www.jam-software.com/shellbrowser_delphi) for this purpose. A timer might work too, I didn't compare both approaches as I use a thread-pool with tasks anyway.
– Joachim MarderMay 12 '14 at 07:48
@Joachim, agree with a tick count calculation (also mentioned in my previous comment). What I'm pretty much against is using thread for triggering `Invalidate` since the `WM_TIMER` message with `WM_PAINT` are on the same (lowest) level of priority and when the app. is not able to process `WM_TIMER` *on time*, it's certainly not able to paint *on time* as well. It might make sense when you were calling `Refresh` which overcomes Windows messaging and *injects* immediate drawing to the control.
– TLamaMay 12 '14 at 10:00
Any other solutions? – AlexLL May 11 '14 at 16:41