Solved

animation in vb

Posted on 1998-10-21
9
248 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:ameba
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

12 Experts available now in Live!

Get 1:1 Help Now