Zero
Dec 27th, 2000, 09:58 PM
This is rather useless, but it's a nifty procedure for introducing a form to the screen that I just wrote. I don't feel like posting a demo, so I'll leave that up to you. You'll need five forms. Form1, Form2, Form3, Form4, and Main. The Form#'s should have a background color of straight green (RGB 0, 255, 0), as should the Main form. The Form#'s should be border style 0 (none) and the Main form can be whatever the hell you want. Main should be set to CenterScreen, too. You'll have to declare the Sleep API call, too. With that said, on with the show:
Make the startup object Main. Pop it open and put this in the Form_Load.
Private Sub Form_Load()
Call OpenAnim
End Sub
Now, of course, we've gotta make the OpenAnim sub. Excuse my sloppy coding.
Sub OpenAnim()
' Form1 and 2 are horizontal.
' Form3 and 4 are vertical.
Main.Visible = True
Main.Visible = False 'This is neccesary to get form Main to set it's corrdinates. That's VB for you- go figure.
DoEvents
Part0:
'Starting placement... This'll put the four forms where they need to be, hopefully independent of the placement of Main and your screen resolution.
Form1.Height = Screen.Height / 50
Form1.Width = Main.Width
Form1.Top = Main.Top
Form1.Left = 0 - Form1.Width
Form2.Height = Screen.Height / 50
Form2.Width = Main.Width
Form2.Top = Main.Top + Main.Height - Form2.Height
Form2.Left = Screen.Width
Form3.Width = Screen.Width / 50
Form3.Height = Main.Height
Form3.Top = 0 - Form3.Height
Form3.Left = Main.Left
Form4.Width = Screen.Width / 50
Form4.Height = Main.Height
Form4.Top = Screen.Height
Form4.Left = Main.Left + Main.Width - Form4.Width
Form1.Visible = True
Form2.Visible = True
Form3.Visible = True
Form4.Visible = True
DoEvents
Part1: 'This is where the first stage of animation takes place.
For i = 1 To 400
If Form1.Left < Main.Left Then
Form1.Left = Form1.Left + 50
Else
Form1.Left = Main.Left
End If
If Form2.Left > Main.Left Then
Form2.Left = Form2.Left - 50
Else
Form2.Left = Main.Left
End If
If Form3.Top < Main.Top Then
Form3.Top = Form3.Top + 37.5
Else
Form3.Top = Main.Top
End If
If Form4.Top > Main.Top Then
Form4.Top = Form4.Top - 37.5
Else
Form4.Top = Main.Top
End If
If Form1.Left = Main.Left And Form2.Left = Main.Left And Form3.Top = Main.Top And Form4.Top = Main.Top Then
GoTo Part2
End If
DoEvents
Sleep 10 'You can meddle with this to taste. Smaller numbers are faster.
Next i
Part2:
Sleep 500 'Ditto.
DoEvents
BufferHeight = Main.Height
BufferWidth = Main.Width
Main.Height = 30
Main.Width = 40
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
Main.Visible = True
DoEvents
For i = 1 To 800 'This is the second stage of animation.
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
DoEvents
If Main.Width < BufferWidth Then
Main.Width = Main.Width + (10 * 2)
Else
Main.Width = BufferWidth
End If
If Main.Height < BufferHeight Then
Main.Height = Main.Height + (7.5 * 2)
Else
Main.Height = BufferHeight
End If
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
DoEvents
Sleep 10
If Main.Height = BufferHeight And Main.Width = BufferWidth Then GoTo Part4
Next i
Part4:
Form1.Hide
Form2.Hide
Form3.Hide
Form4.Hide
For i = 255 To 0 Step -1 'Here we change the color of Main from black to green. You can mess with this to change it to whatever you want.
Main.BackColor = RGB(0, i, 0)
DoEvents
Sleep 10
Next i
End Sub
And that's a wrap. You can tack more code onto the end of this to make all the controls that may or may not be on the Main form appear. If anybody else has any nifty animations, post 'em here. I'm always interested in this kind of thing.
~Zero the Inestimable
Make the startup object Main. Pop it open and put this in the Form_Load.
Private Sub Form_Load()
Call OpenAnim
End Sub
Now, of course, we've gotta make the OpenAnim sub. Excuse my sloppy coding.
Sub OpenAnim()
' Form1 and 2 are horizontal.
' Form3 and 4 are vertical.
Main.Visible = True
Main.Visible = False 'This is neccesary to get form Main to set it's corrdinates. That's VB for you- go figure.
DoEvents
Part0:
'Starting placement... This'll put the four forms where they need to be, hopefully independent of the placement of Main and your screen resolution.
Form1.Height = Screen.Height / 50
Form1.Width = Main.Width
Form1.Top = Main.Top
Form1.Left = 0 - Form1.Width
Form2.Height = Screen.Height / 50
Form2.Width = Main.Width
Form2.Top = Main.Top + Main.Height - Form2.Height
Form2.Left = Screen.Width
Form3.Width = Screen.Width / 50
Form3.Height = Main.Height
Form3.Top = 0 - Form3.Height
Form3.Left = Main.Left
Form4.Width = Screen.Width / 50
Form4.Height = Main.Height
Form4.Top = Screen.Height
Form4.Left = Main.Left + Main.Width - Form4.Width
Form1.Visible = True
Form2.Visible = True
Form3.Visible = True
Form4.Visible = True
DoEvents
Part1: 'This is where the first stage of animation takes place.
For i = 1 To 400
If Form1.Left < Main.Left Then
Form1.Left = Form1.Left + 50
Else
Form1.Left = Main.Left
End If
If Form2.Left > Main.Left Then
Form2.Left = Form2.Left - 50
Else
Form2.Left = Main.Left
End If
If Form3.Top < Main.Top Then
Form3.Top = Form3.Top + 37.5
Else
Form3.Top = Main.Top
End If
If Form4.Top > Main.Top Then
Form4.Top = Form4.Top - 37.5
Else
Form4.Top = Main.Top
End If
If Form1.Left = Main.Left And Form2.Left = Main.Left And Form3.Top = Main.Top And Form4.Top = Main.Top Then
GoTo Part2
End If
DoEvents
Sleep 10 'You can meddle with this to taste. Smaller numbers are faster.
Next i
Part2:
Sleep 500 'Ditto.
DoEvents
BufferHeight = Main.Height
BufferWidth = Main.Width
Main.Height = 30
Main.Width = 40
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
Main.Visible = True
DoEvents
For i = 1 To 800 'This is the second stage of animation.
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
DoEvents
If Main.Width < BufferWidth Then
Main.Width = Main.Width + (10 * 2)
Else
Main.Width = BufferWidth
End If
If Main.Height < BufferHeight Then
Main.Height = Main.Height + (7.5 * 2)
Else
Main.Height = BufferHeight
End If
Main.Left = Screen.Width / 2 - Main.Width / 2
Main.Top = Screen.Height / 2 - Main.Height / 2
DoEvents
Sleep 10
If Main.Height = BufferHeight And Main.Width = BufferWidth Then GoTo Part4
Next i
Part4:
Form1.Hide
Form2.Hide
Form3.Hide
Form4.Hide
For i = 255 To 0 Step -1 'Here we change the color of Main from black to green. You can mess with this to change it to whatever you want.
Main.BackColor = RGB(0, i, 0)
DoEvents
Sleep 10
Next i
End Sub
And that's a wrap. You can tack more code onto the end of this to make all the controls that may or may not be on the Main form appear. If anybody else has any nifty animations, post 'em here. I'm always interested in this kind of thing.
~Zero the Inestimable