home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Scroller"
- ClientHeight = 1635
- ClientLeft = 1140
- ClientTop = 1515
- ClientWidth = 6690
- Height = 2040
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 1635
- ScaleWidth = 6690
- Top = 1170
- Width = 6810
- Begin VB.Timer Timer1
- Left = 4440
- Top = 480
- End
- Begin VB.Label Label2
- Caption = "Label2"
- Height = 255
- Left = 1680
- TabIndex = 1
- Top = 240
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Label1"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1455
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub Form_Load()
- 'give Label1 a caption
- Label1.Caption = "Look ma! wrap-around scrolling!"
- 'Autosize both labels
- Label1.AutoSize = True
- Label2.AutoSize = True
- 'Uniform the labels
- Label2.Top = Label1.Top
- Label2.Caption = Label1.Caption
- 'Hide label2 offscreen
- Label2.Left = Form1.Width + 20
- 'Set the timer to a nice smooth time
- timer1.Interval = 90
- 'Enable the timer
- timer1.Enabled = True
- 'Store the Form's width in case of resize
- FrmSize$ = Form1.Width
- End Sub
- Private Sub Form_Resize()
- '*******************************
- 'NOTE: this section is only needed if the form is going to change size
- '*******************************
- 'We dont want crashes from devide by 0
- If FrmSize$ > 0 Then
- 'If Label2 is farther from the forms left border
- 'than Label1 then
- If Label1.Left < Label2.Left Then
- 'make sure Label2 stays offscreen
- Label2.Left = Form1.Width + 20
- 'find how far (percent) the label is across the old screen
- Percnt$ = Label1.Left / FrmSize$
- 'find out the distance where the label should be
- 'based on the percentage and put it there
- Label1.Left = Form1.Width * Percnt$
- End If
- 'If Label1 is farther from the forms left border
- 'than Label2 then
- If Label2.Left < Label1.Left Then
- 'make sure Label2 stays offscreen
- Label1.Left = Form1.Width + 20
- 'find how far (percent) the label is across the old screen
- Percnt$ = Label2.Left / FrmSize$
- 'find out the distance where the label should be
- 'based on the percentage and put it there
- Label2.Left = Form1.Width * Percnt$
- End If
- End If
- 'Store the form width just in case we have to go through
- 'this again
- FrmSize$ = Form1.Width
- End Sub
- Private Sub timer1_Timer()
- 'If Label1 is farther from the forms left border
- 'than Label2 then
- If Label1.Left < Label2.Left Then
- 'move the Label1 closer to the left border
- Label1.Left = Label1.Left - 25
- 'If the Label1 is completely offscreen then send it
- 'to the other side of the form to wait for its turn
- If Label1.Left + Label1.Width <= 0 Then Label1.Left = Form1.Width + 10
- 'If Label1 is partially hidden then start scrolling
- 'Label2
- If Label1.Left < 0 Then Label2.Left = Form1.Width + Label1.Left
- End If
- 'If Label2 is farther from the forms left border
- 'than Label1 then
- If Label2.Left < Label1.Left Then
- 'move the Label2 closer to the left border
- Label2.Left = Label2.Left - 25
- 'If the Label2 is completely offscreen then send it
- 'to the other side of the form to wait for its turn
- If Label2.Left + Label2.Width <= 0 Then Label2.Left = Form1.Width + 10
- 'If Label2 is partially hidden then start scrolling
- 'Label1
- If Label2.Left < 0 Then Label1.Left = Form1.Width + Label2.Left
- End If
- End Sub
-