Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

animated gif in visual foxpro form

ravicoder

Programmer
Apr 29, 2006
31
IN
Hi all

I'm trying to display an animated gif in a form when some data is being retrieved or when some processing is going on.

I've tried image control and webbrowser control, but I can't get the gif to animate. Any advice/sample code would be appreciated

thanks
 
Can you post your gif?

In VFP9 this should show the FoxPro logo morphing from new to old logo and back:
Code:
_screen.AddObject("image1","image")
_screen.image1.Picture=Home()+"GRAPHICS\GIFS\MORPHFOX.GIF"
_screen.image1.Visible = .t.
This doesn't require any code to start animating, just setting the picture. Obviously, this MORPHFOX.GIF is part of VFP9, not earlier versions,. But in principle I never needed any code to animate a GIF or even trigger starting the animation with any code, an animated GIF is just animated in itslef, so the OS rendering of it does that.
 
I know VFP9 introduced PNG rendering and SP1 or 2 fixed a bg with PNG transparency. That has nothing to do with GIF, but pretty sure VFP9s integration with GDI+ is best in the last version of it, if you use previous VFP versions, that might be the root cause of the GIF not working. If you could post your GIF, we'd not only see whether it animates in several browsers, I'd also verify whether it works in VFP9.
 
If VFP's animation fails, then get a copy of "gif89.dll" from the internet. (see here: https://www.vbforums.com/showthread.php?79007-gif89-dll
Copy that one file into \Windows\SYSWOW64, do a "REGSVR32 gif89.dll" from an administrative CMD in that directory.
Then in your form add an OleControl to your form and in the selection dialog choose "GIF89 CLASS".
Assign your giffile to the Filename property of that class:
Thisform.OleControl1.FileName = GetPict("gif")
 
Last edited:
This doesn't require any code to start animating, just setting the picture. Obviously, this MORPHFOX.GIF is part of VFP9, not earlier versions,. But in principle I never needed any code to animate a GIF or even trigger starting the animation with any code, an animated GIF is just animated in itslef, so the OS rendering of it does that.
The funny thing is I've never really thought about adding an animated GIF to a form, but I just tested it and tried two ways using the MORPHFOX.GIF file, and you are correct, it works perfectly using the built-in Image control in the latest VFP without needing anything else.

I tried it two ways... Once by adding a regular Image control from the Designer, then once by adding it to a Container programmatically in the Init.

I guess I noticed that older versions didn't support animation so I assumed the newer versions didn't support it and didn't try again until your post. Well done.
 
Well, putting an image control on a form and setting the Picture interactively (double click the picture property and pick the MORPHFOX.GIF from the file open dialog) it even animates in design mode immediately. I don't see it depend on how you set the picture.
 
Well, putting an image control on a form and setting the Picture interactively (double click the picture property and pick the MORPHFOX.GIF from the file open dialog) it even animates in design mode immediately. I don't see it depend on how you set the picture.
I tend to place 99% of images directly from the IDE, but there are times where the only useful way is to do it in the Init code, such as when the filename is taken from the data itself, such as a customer's logo, or in cases where I want the logo to visually reflect the status of a field. For example, drawing attention to an inactive customer, or a customer who is COD vs ON ACCOUNT.

What I didn't realize was that they eventually added support for animated GIFs.
 
they eventually added support for animated GIFs.
I think it always was done by the OS layer. I think I already used GIFs in VFP7. I could misremember that - I might have only used the transparency feature in an unanimated GIF, but I also remember I used BMP with a MSK mask file, that was better in some aspect., but clearly not about animation, which only GIF would support as image, otherwise there are even examples with simple AVIs, like the SEARCH.AVI you also still find in HOME()+"GRAPHICS\VIDEOS\SEARCH.AVI".

There was some kind of switch with VFP9 to also support PNG and gdiplus.dll became part of the runtime libraries you had to release with a VFP application. I remember that was causing some effects on reports, generally printing a few % wider and causing ***** in numeric report controls that were precisely dimensioned in previous versions. If I'm wrong about GIF animation support in VFP7 the animation support simply was a sideeffect of delegating graphics to GDI+. The switch to GDI+ surely allowed support of more GIFs, but I think there are also GIF files that won't work with GDI+, just like some PNGs with alpha channel still don't work with VFP9. GDI+ is good, even quite excellent in resizing images with high quality of edge shaprness, for example, but it's not the definitive image library.
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top