VB声明
Declare Function PolyBezier& Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long)
Declare Function PolyBezierTo& Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long)
说明
描绘一条或多条贝塞尔(Bezier)曲线。PolyBezierTo用于将当前画笔位置设为前一条曲线的终点
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
hdc Long,要在其中绘图的设备场景
lppt POINTAPI,指定一个POINTAPI结构数组。其中的第一个结构指定了起点。剩下的点三个一组——包括两个控件点和一个终点
原文:An array of POINTAPI structures. The first structure specifies the starting point. The remaining points are in groups of three, consisting of two control points and an end point.
cPoints Long,lppt数组的总点数
Private Declare Function PolyBezierTo& Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long)
Private Type POINTAPI
x As Long
y As Long
End Type
Dim bpoints(30) As POINTAPI, bpoints2(12) As POINTAPI
Private Sub Command1_Click()
Picture1.Scale (0, 0)-(640, 480)
Picture1.ScaleMode = 3
PolyBezierTo Picture1.hdc, bpoints(0), 30 '--->3的倍数
End Sub
Private Sub Command2_Click()
Picture1.Scale (0, 0)-(640, 480)
Picture1.ScaleMode = 3
Picture1.ForeColor = Picture1.BackColor
PolyBezierTo Picture1.hdc, bpoints(10), 3 '-->抹去一段
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Dim i As Integer
Dim j As Long
Picture1.Scale (0, 0)-(640, 480)
Picture1.ScaleMode = 3 '------------------>设置scalemode属性为pixels(像素),将API默认的坐标系和vb中使用的坐标系对应起来
For i = 0 To 30
bpoints(i).x = 32 + i * 20
bpoints(i).y = 100 + 100 * Sin((bpoints(i).x * 2 * 3.14159 / 640))
Picture1.PSet (bpoints(i).x, bpoints(i).y), vbBlue
Next
End Sub