Solved

animation in vb

Posted on 1998-10-21
9
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

751 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