|
-
May 12th, 2003, 09:01 PM
#1
Thread Starter
Fanatic Member
Draw line and timer?
I am drawing a line from point A to B. I want it to take about 1 second to complete. I also want to have the line draw at run time and appear to draw over that 1 second from A to B. I am doing it with a for loop and running a variable up to a very high count. This isnt an effiecent way of doing it. Here is my code:
Code:
Private Sub cmdClientMenu_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdFind.Visible = True Then
Exit Sub
End If
lineMC.Visible = True
lineMC.X1 = 2520
lineMC.Y1 = 2880
MyXPos = lineMC.X1
MyYPos = lineMC.Y1
For i = 0 To 110000
If i = 10000 Or i = 20000 Or i = 30000 Or i = 40000 Or i = 50000 Or i = 60000 _
Or i = 70000 Or i = 80000 Or i = 90000 Or i = 100000 Or i = 110000 Then
frmSalon.lineMC.X2 = MyXPos + 120
frmSalon.lineMC.Y2 = MyYPos - 120
frmSalon.Refresh
MyXPos = frmSalon.lineMC.X2
MyYPos = frmSalon.lineMC.Y2
End If
Next
frmSalon.cmdFind.Visible = True
End Sub
Any help would be great.
-
May 12th, 2003, 09:40 PM
#2
Fanatic Member
VB Code:
Option Explicit
Dim i As Integer
Const LINE_LENGTH As Integer = 6000
Private Sub Form_Load()
With Line1
.Visible = False
.X1 = 200
.X2 = 200
.Y1 = 1000
.Y2 = 1000
End With
End Sub
Private Sub Command1_Click()
With Timer1
.Interval = 25
.Enabled = True
End With
With Line1
.Visible = True
.X1 = 200
.X2 = 200
.Y1 = 1000
.Y2 = 1000
End With
i = 0
End Sub
Private Sub Timer1_Timer()
i = i + Timer1.Interval
If i = 1000 Then
Timer1.Enabled = False
Else
IncrementLine
End If
End Sub
Private Sub IncrementLine()
Dim sngPercent As Single
sngPercent = i / 1000
Line1.X2 = (LINE_LENGTH * sngPercent) + Line1.X1
End Sub
This just needs a commandbutton, a timer and a line. You may have to play with the timer interval a bit to get the effect you want - drawing the line takes time so it isn't very accurate, but I think it will get you started.
"Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!
Resistance is futile, you will be compiled . . . Please!
-
May 12th, 2003, 10:22 PM
#3
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|