Solved

animation in vb

Posted on 1998-10-21
9
250 Views
Last Modified: 2006-11-17
I have vb 4.0 and I would like tp put a .gif file for
background on the vb application. If that possible ?
You can assume I have back.gif file. You can design a empty
or just very simple appplication and the background will be
back.gif.

I would like a complete code.

Thank you
0
Comment
Question by:rebert_herry
  • 5
  • 4
9 Comments
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 1441056
There is no code - just set property Form1.Picture
You mean form, not application? Or you mean Wallpaper on your desktop?
0
 

Author Comment

by:rebert_herry
ID: 1441057
ok , it is a vb application, it isn't a Wallpaper on my desktop.
Just a animation file on the vb application form.
I have tried to set  Form1.Picture , but when I ran the apllication, it gave me a run time error,
said that my back.gif is not allowed.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1441058
Did you set picture property? It is allowed, I think from VB4/32 (it is not in the file type list, you must use All Files to select it).
When do you get error - when setting property or when running application? And you cannot use annimated .GIF - I tried simple GIF, it works.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:rebert_herry
ID: 1441059
I think it gave me an error, when I set the property.
you say you tried simple gif and it worked, why not you gave me the code
I think it will help me a lot. thank you
0
 
LVL 15

Expert Comment

by:ameba
ID: 1441060
Try another GIF or JPG.
I didn't use any code. I just set property "Picture" of a form.
But, you can use code:

Private Sub Form_Load()
    Form1.Picture = LoadPicture("E:\Win95\MSAPPS\GRPHFLT\ms.gif")
End Sub

Maybe it works here in my VB4, because I have also VB5 on the same PC.
0
 

Author Comment

by:rebert_herry
ID: 1441061
ok ! It is working, I can see the gif file as background. But I have told you it is animation file. But I just can't see the background changed. Why ?
0
 
LVL 15

Expert Comment

by:ameba
ID: 1441062
Because it is not supported in VB. To have animation, you will have to use timer and change background picture yourself.
But animated GIF and JPG files will show only first plane.

To use GIF and JPG you will have to use a control. E.g. you can try WEB browser control. To try this, press add form and then select "Browser" from existing templates. Set its MDIChild property to False. You can then use:

Private Sub mnuViewBrowser_Click()
    Dim frmB As New frmBrowser
    frmB.StartingAddress = "E:\WIN95\Desktop\cookbook.gif"
    frmB.Show
End Sub

But, WEB browser control is not good background. You can place some controls (e.g. Command buttons) on top of it, but for some controls (labels, shapes) you will have to add Picturebox as container. Labels alone will always go behind WEB browser control.
You will also have to require IE4 instalation for your programs to work.

So, I suggest modifying picture in Timer event and not using animated GIFs.
0
 

Author Comment

by:rebert_herry
ID: 1441063
OK. If I want to use timer event . How ? like
I have 3 files named f1.gif, f2.gif and f3.gif. These files will be  used as background.
So, first gif will be f1.gif, then after 1 second, will be change to f2.gif and so on, repeatly.
How ?
Can you gave me a complete code ?
Thank a lot ?
0
 
LVL 15

Expert Comment

by:ameba
ID: 1441064
Add Picture Box to your form. Set its visible property to False and Index to 0.
Now copy Picture1 and paste 2 times.
You have Picture1(0),Picture1(1) and Picture1(2). Set Picture property for your picture boxes to be "f1.gif", "f2.gif", "f3.gif"
Add timer control, set Interval=1000
Add this code:
Private Sub Timer1_Timer()
    Static flop As Integer
    flop = flop + 1
    If flop = 3 Then flop = 0
    Picture = Picture1(flop).Picture
End Sub

' ClipControls of your form must be set to True
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question