Delphi XE 7 VCL 中的动画 gif

Animated gif in Delphi XE 7 VCL

我在 delphi 2010 和 XE7

中尝试了此处建议的解决方案

How to use Animated Gif in a delphi form

他们都引发了以下消息的异常

"Exception class EInvalidCast with message 'Invalid class typecast'."

您参考的代码是:

(Image1.Picture.Graphic as TGIFImage).Animate := True;

错误消息表明检查的as 转换失败。这意味着 Image1.Picture.Graphic 不是 TGIFImage 的后代。无论您将什么放入图像控件中,它看起来都不是 GIF 图像。

我知道这个答案没有为您提供运行程序的精确步骤。但是,我相信第一步是了解错误消息的含义。一旦你明白了,你就知道在哪里寻找解决方案。

问题出在组件上。在 Delphi 2010 中,JEDI VCL 将图形 class 更改为 TJvGIFImage,在 XE7 图形 class 中,devExpress.after 将图形 class 更改为 TdxSmartImage 我从安装包中删除了相关包,问题已解决.

感谢您的帮助。