GIF's in Visual Basic

Is it possible to display a gif in VB using the picture box or image control, and if so how do I do it?  I have been able to display the gif in the application but it shows up as a 'static' image.  Is there any way that I can make it "Move"?

Thanks

Mark
LVL 1
m_durnellAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
LeithauserConnect With a Mentor Commented:
<<I managed to get it to work as you suggested, although I can get it to work by setting up a button (when
clicked) I would like it to appear at start up.  Any ideas from you would be appreciated.>>

   I do not understand. If you include the
Call WebBrowser1.Navigate(MyFile.gif)
in the Form_Load module of the form, the graphic should be in place before the form becomes visible. You might even include a DoEvents right after the call. Is this not happening properly?
0
 
LeithauserCommented:
 Would you consider using a WebBrowser control instead of a picture or image control? Have the WebBrowser control load your gif file using
Call WebBrowser1.Navigate(MyFile.gif)
  You would have to distribute the gif file with the program, but the WebBrowser control does respond to click and such.
0
 
m_durnellAuthor Commented:
I would consider anything, thanks for your help, but how do I go about using this control - Where is it?
Cheers!
 
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LeithauserCommented:
The following directions may vary slightly, depending on which version of VB you are using. These are for VB 4.

Click on Tools/Custom controls.
Scroll down to Microsoft Internet Controls
Click on the box to mark it with an X
Click on the OK button.

This should add a control to your toolbar that looks like Earth. Add this control to yor form and size it like you would any other control.

To display the gif, put the code
Call WebBrowser1.Navigate(MyFile.gif)
somewhere, probably in the Form Load module. Where I have used MyFile.gif above, include the path to your gif. If the gif is in the same folder as the app, MyFile.gif should be sufficient.
0
 
Richie_SimonettiIT OperationsCommented:
0
 
priya_pbkCommented:
I guess what m_durnell wants is to make his image "move". If one puts it in an image control or picture control or a web control, this again would remain static.

Maybe you can put a timer control with your image or a picture control. Try something like this:

Put an couple of image/picture controls on your form along with a Timer control

Set the Timer controls "Interval" property as 1000 (ie 1 sec) and in the Timer1_Timer() event show the gif file in different picture boxes hiding and showing it. That is show Picture1 and hide picture2 and picture 3.
Assuming you have loaded your gifs to picture1, 2 and 3.

This is just a workaround. I dont think the finish would be smooth enough. But obviously you wont have a static gifs. The user will surely feel that it is an animation but surely not a static image.

Hope you can try this.

-priya

0
 
LeithauserCommented:
It seems to me that my suggestion of using the WebBrowser control to display the image is simpler. I gave it a quick test on my computer and it seems to work fine.
0
 
priya_pbkCommented:
but did'nt you want to make it "Move"????
0
 
Richie_SimonettiIT OperationsCommented:
H i m_durnell, any progress?
Maybe there is a misconception here: when you say "move", yiu are talking about "animation an animated gif" or "moving the image from, ie, point A to point B"?
0
 
m_durnellAuthor Commented:
Hi,

Richie is right I want to use an animated gif.  I dont want to move the image from one point to another.

Mark
0
 
Richie_SimonettiIT OperationsCommented:
If you don't want to use the code from www,mvps.org/vbnet you could use a third party control called anigif.ocx.
http://www.allapi.net/php/redirect/redirect.php?action=download&id=86
http://www.allapi.net/php/redirect/redirect.php?action=download&id=342
0
 
LeithauserCommented:
m_durnell:

   Did you try out the suggestion I made to put a WebBrowser control on the form? Worked fine for me.
0
 
m_durnellAuthor Commented:
Hi,

I do not know how to add the control that Leithauser suggested I am using version 6.

0
 
LeithauserCommented:
  In VB 6, Click on the Projects menu at the top. Click on Components. Scroll down to Microsoft Internet controls and click on the box to check it. Click on Apply button and then Ok button. A picture of Earth will appear on your tool bar. Use this just like any other control, like a picture box, to put it on your form and size it.
   The picture cannot be selected during design time, so you must distrubute the gif along with the project and put
Call WebBrowser1.Navigate(MyFile.gif) in the form Load module. The gif should show in the control and be fully animated, just like it looks in a Web page. Experiment with sizing the box to fit the gif. Let me know if you have any other questions.
0
 
m_durnellAuthor Commented:
Leithauser,

I managed to get it to work as you suggested, although I can get it to work by setting up a button (when clicked) I would like it to appear at start up.  Any ideas from you would be appreciated.

Regards

Mark
0
 
Richie_SimonettiIT OperationsCommented:
Of course you could use the approach that you like but just take in mind two things:
1) Wasted resources
2) You need to "hide" scroll bar too.
0
 
m_durnellAuthor Commented:
It worked perfect.  Thanks for that - It made me think a little.

Regards

Mark
0
 
LeithauserCommented:
To Richie Simonetti:
   If your comment was in regard to my suggestion of using the WebBrowser control, there is no scroll bar if you size the control precisely to fit the gif. Rememebr, you are talking about knowing exactly what image you plan to put there, so a little experimentation in the design stage can size the control perfectly to fit the gif that will go there.
   As for wasted resources, any way you do it, ther ewill be some wasted resource. In general, the WebBrowser control can be one alternative to displaying images that are meant for Web pages.
0
 
Richie_SimonettiIT OperationsCommented:
Leithauser, nothing against you in my comment.
I used webbrowser control to display animated gif (and Java applets) until i found a less resource usage way.
regarding scrollbar, there is not a great problem. I know a couple of ways to hide it without know the exact size of the image.
Happy codding!
Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.