Solved

animation in vb

Posted on 1998-10-21
9
249 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now