Quote:

>Hi, all, I need to draw arrowlines at run time. Does

>anybody know how to do that?

Option Explicit

Private Sub DrawArrow(ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As

Long, ByVal y2 As Long, ByVal colr As OLE_COLOR)

Dim x3 As Long, x4 As Long

Dim y3 As Long, y4 As Long

Dim xs As Long, ys As Long

Dim theta As Single

Dim L As Long

Const pi = 3.14159

'line between coords x1, y1 and x2, y2

'want a line from x2, y2 of length L, in direction 45 deg clockwise

from orig line direction

'direction of orig line is theta:

L = 180

xs = x2 - x1

ys = y2 - y1

If xs <> 0 Then

theta = Atn(ys / xs)

If xs < 0 Then

theta = theta + pi

End If

Else

If ys < 0 Then

theta = 3 * pi / 2 '90

Else

theta = pi / 2 '270

End If

End If

'rotate direction

theta = theta - 4 * pi / 5 ' - 3 * pi / 4

'find end of one side of arrow:

x3 = L * Cos(theta) + x2

y3 = L * Sin(theta) + y2

'rotate other way for other arrow line

theta = theta + 8 * pi / 5 '- pi / 2

x4 = L * Cos(theta) + x2

y4 = L * Sin(theta) + y2

'draw the lines

Line (x1, y1)-(x2, y2), colr

Line (x2, y2)-(x3, y3), colr

Line (x2, y2)-(x4, y4), colr

End Sub

Private Sub Form_Load()

Me.DrawMode = 7

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As

Single, Y As Single)

Static OldX As Single

Static OldY As Single

If Button Then Exit Sub

If OldX Then

DrawArrow Me.Width / 2, Me.Height / 2, OldX, OldY, &HFFFFFF

End If

DrawArrow Me.Width / 2, Me.Height / 2, X, Y, &HFFFFFF

OldX = X

OldY = Y

End Sub

Jim Deutch

MS Dev MVP