单击按钮时如何以Windows窗体显示.gif图像 [英] How to display .gif image in windows form when clicking button

查看:81
本文介绍了单击按钮时如何以Windows窗体显示.gif图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,当我点击按钮时,我想以Windows窗体显示loading.gif图像。在执行调用方法之后,需要隐藏loading.gif图像



i使用了图片框和图像但是当我点击按钮时loading.gif没有动画它只是显示为静态图像,但我想显示动画图像,直到需要执行调用方法。





你有什么可以帮助我....

解决方案

< blockquote>听起来你没有得到重绘但有正确的方向,如果你没有禁用图片框,picturebox加上图片就可以了。



我的猜测是你应该将方法的工作部分转移到另一个线程以启用ui线程的绘制,并且它将起作用,因为你的ui线程在不忙时定期重新渲染



或许使用后台工作程序,线程池或手动创建的线程来完成工作,让ui成为ui,它看起来很清晰


.NET Framework 不支持gif动画。当您使用Image类加载动画gif时,只会显示第一帧。


如果需要,您也可以使用DirectX,但它有点复杂......



这个网站是意大利语,但我认为这是一个很好的资源,也许你可以用谷歌翻译翻译它。搜索DirectX9教程并查找audiovideo。

http://robydx.135.it/ [< a href =http://robydx.135.it/target =_ blanktitle =New Window> ^ ]


Hi when i click the button, i want to display loading.gif image in windows form. after the calling methods has been executed the loading.gif image need to be hidden

i used picturebox and image but when i click the button the loading.gif not animated it's just displaying as static image but i want to display animated image until the calling method need to be executed.


how is possible can you help me....

解决方案

Sounds like you don't get repaint happening but have the right direction, picturebox plus image will work if you do not disable the picture box.

My guess is that you should offhand the working part of the method to another thread to enable paints of the ui thread to happen, and it will work because your ui thread repaints periodically when not busy

perhaps use a background worker, threadpool or manually created thread to do the work and let ui be ui and it will look sharp


.NET Framework does not support gif animation. When you load an animated gif using Image class, just the first frame will be displayed.


If you want, you can also use DirectX, but it is a bit complicated...

This website is in Italian, but I think it's a good resource, maybe you can translate it with Google Translate. Search for DirectX9 Tutorials and look for audiovideo.
http://robydx.135.it/[^]


这篇关于单击按钮时如何以Windows窗体显示.gif图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆