-
Animation
I have a form with (to make things simple) a ListBox control and a Frame control, both streching vertically to occupy the height of the whole form.
As I want to accomodate users running at lower resoltions, I want to make the Frame "autohidable" :), meaning that normally I want the ListBox to take up the whole form, and clicking a button makes the Frame slide into view.
I can do this without animation (just change the Visible property), but how can I make animation to do this? It should be something like the a menu sliding in Windows 98, a task pane sizing in Windows XP, etc.
I could just do it in a For loop, incrementing the size of the frame by 10 twips each time, but the Frame would resize faster or slower on different systems.
Just reply if this even makes sense! :)
-
You could use a timer control, and add the code that do the "animation" in the Timer event. The Timers time event should trigger with the same interval even if the computers CPU varies..
-
eh.. that came out a bit wrong.. dont't think that one computers cpu will vary that much... but you get my point ? :)
-
Yep! makes sense to me
this uses a picture box and a menu item called mnuX
Code:
Option Explicit
Private Sub Form_Load()
Picture1.Left = 0
Picture1.Width = Me.ScaleWidth
End Sub
Private Sub mnuX_Click()
If mnuX.Caption = "hide" Then
hidePic
mnuX.Caption = "show"
Else
showPic
mnuX.Caption = "hide"
End If
End Sub
Private Sub Pause(secs As Single)
Dim sngStopVal As Single
sngStopVal = Timer + secs
While sngStopVal > Timer
DoEvents
Wend
End Sub
Private Sub showPic()
While Picture1.Top > Me.ScaleHeight - Picture1.Height
Picture1.Top = Picture1.Top - 100
Pause 0.01
Wend
End Sub
Private Sub hidePic()
While Picture1.Top < Me.Height
Picture1.Top = Picture1.Top + 100
Pause 0.01
Wend
End Sub
-
While it's not essential to all life on Earth, but will the code produce animation that runs smoother on faster machines and crappier on slower machines?