首页 > 代码库 > VB API 之 第九课 图像编程(二)
VB API 之 第九课 图像编程(二)
用到2个API函数,Polyiine,Polylineto函数原型如下
Declare Function Polyline Lib "gdi32" Alias "Polyline" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function PolylineTo Lib "gdi32" Alias "PolylineTo" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
功能说明
用来绘制线段
参数
hdc: Long //设备的句柄
lpPoint 指向一个POINTAPI的结构。
nCount:Long //lpPoint数组的点数。
示例:
Option ExplicitPrivate Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As point, ByVal nCount As Long) As LongPrivate Declare Function PolylineTo Lib "gdi32" (ByVal hdc As Long, lppt As point, ByVal cCount As Long) As LongPrivate Type point x As Long y As LongEnd Type Dim Flag1 As BooleanDim Flag2 As BooleanDim Pos(10) As pointDim i As IntegerPrivate Sub Command1_Click() Flag1 = True Flag2 = FalseEnd SubPrivate Sub Command2_Click() Flag1 = False Flag2 = TrueEnd SubPrivate Sub Command3_Click() Flag1 = False Flag2 = FalseEnd SubPrivate Sub Command4_Click() Me.Picture1.ClsEnd SubPrivate Sub Form_Load() Flag1 = False Flag1 = False ‘禁止绘图 Me.ScaleMode = 3 Me.Picture1.ScaleMode = 3 ‘设置对象坐标的度量单位为像素 i = 0End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) If Flag1 Then Pos(i).x = x Pos(i).y = y If (i >= 3) Then Polyline Me.Picture1.hdc, Pos(0), 4 Me.Picture1.Circle (x, y), 3 i = 0 Exit Sub End IfEnd If‘利用PolyLine函数绘图If Flag2 Then Pos(i).x = x Pos(i).y = y If (i >= 3) Then PolylineTo Me.Picture1.hdc, Pos(0), 3 Me.Picture1.Circle (x, y), 3 i = 0 Exit Sub End IfEnd If‘利用PolyLineTo函数绘图If (i <= 3) Then i = i + 1 Me.Picture1.Circle (x, y), 3End IfEnd Sub
VB API 之 第九课 图像编程(二)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。