Dim oldy& Private Sub Command1_Click() oldy = Me.CurrentY Print Chr(41467) Line (Me.CurrentX, oldy + 80)-(3000, oldy + 80), QBColor(0) Me.CurrentY = oldy Print Chr(41466); End Sub
sub arrow(x1 as integer,y1 as integer,x2 as integer,y2 as integer,color as long) dim theta as single theta=atan((y2-y1)/(x2-x1)) line(x1,y1)-(x2,y2),color line(x1,y1)-(x1+length*cos(theta),y1+length*sin(theta)) ...... end sub
我先给你写一个简单的例子,你可以再此基础上进一步发挥。Option ExplicitPrivate Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long) As Long Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long 'Private Declare Function LineDDA Lib "gdi32" (ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal lpLineDDAProc As Long, ByVal lParam As Long) As Long Private Const BLACK_BRUSH = 4Private Type POINTAPI x As Long y As Long End Type Private Sub DrawTrigon(x1 As Long, x2 As Long, y As Long) Dim hBrush As Long, hPrevBrush As Long Dim points(1 To 4) As POINTAPI
Me.ScaleMode = vbPixels
points(1).x = x2 - 10 points(1).y = y - 5
points(2).x = x2 - 10 points(2).y = y + 5
points(3).x = x2 points(3).y = y
'画直线 MoveToEx Me.hdc, x1, y, 0 LineTo Me.hdc, x2, y '画三角 hBrush = GetStockObject(BLACK_BRUSH) hPrevBrush = SelectObject(Me.hdc, hBrush) Call Polygon(Me.hdc, points(1), 3) Call SelectObject(Me.hdc, hPrevBrush) End SubPrivate Sub Form_Paint() DrawTrigon 10, 200, 50 End Sub
Private Sub Command1_Click()
oldy = Me.CurrentY
Print Chr(41467)
Line (Me.CurrentX, oldy + 80)-(3000, oldy + 80), QBColor(0)
Me.CurrentY = oldy
Print Chr(41466);
End Sub
dim theta as single
theta=atan((y2-y1)/(x2-x1))
line(x1,y1)-(x2,y2),color
line(x1,y1)-(x1+length*cos(theta),y1+length*sin(theta))
......
end sub
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
'Private Declare Function LineDDA Lib "gdi32" (ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal lpLineDDAProc As Long, ByVal lParam As Long) As Long
Private Const BLACK_BRUSH = 4Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub DrawTrigon(x1 As Long, x2 As Long, y As Long)
Dim hBrush As Long, hPrevBrush As Long
Dim points(1 To 4) As POINTAPI
Me.ScaleMode = vbPixels
points(1).x = x2 - 10
points(1).y = y - 5
points(2).x = x2 - 10
points(2).y = y + 5
points(3).x = x2
points(3).y = y
'画直线
MoveToEx Me.hdc, x1, y, 0
LineTo Me.hdc, x2, y
'画三角
hBrush = GetStockObject(BLACK_BRUSH)
hPrevBrush = SelectObject(Me.hdc, hBrush)
Call Polygon(Me.hdc, points(1), 3)
Call SelectObject(Me.hdc, hPrevBrush)
End SubPrivate Sub Form_Paint()
DrawTrigon 10, 200, 50
End Sub