VB API 之 第九课 图像编程(二)
2014-10-15 17:22
399 查看
用到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数组的点数。
示例:
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 Explicit Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As point, ByVal nCount As Long) As Long Private Declare Function PolylineTo Lib "gdi32" (ByVal hdc As Long, lppt As point, ByVal cCount As Long) As Long Private Type point x As Long y As Long End Type Dim Flag1 As Boolean Dim Flag2 As Boolean Dim Pos(10) As point Dim i As Integer Private Sub Command1_Click() Flag1 = True Flag2 = False End Sub Private Sub Command2_Click() Flag1 = False Flag2 = True End Sub Private Sub Command3_Click() Flag1 = False Flag2 = False End Sub Private Sub Command4_Click() Me.Picture1.Cls End Sub Private Sub Form_Load() Flag1 = False Flag1 = False '禁止绘图 Me.ScaleMode = 3 Me.Picture1.ScaleMode = 3 '设置对象坐标的度量单位为像素 i = 0 End Sub Private 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 If End 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 If End If '利用PolyLineTo函数绘图 If (i <= 3) Then i = i + 1 Me.Picture1.Circle (x, y), 3 End If End Sub
相关文章推荐
- vB API 之 第八课 图像编程(一)
- VB API 之 第十课 图像编程(三)
- VB的API编程精粹(好像本teach 有不少的bug)
- VB的API编程精粹
- 游戏手柄编程DEMO 基于 VB.NET+API 暂无力反馈
- VB之Win32 API编程--判断本地或远程文件是否存在的简易方法
- VB的API编程精粹(二)
- vb编程:windwosapi全攻略
- VB编程:WindwosAPI全攻略
- VB编程:WindwosAPI全攻略
- VB编程:WindwosAPI全攻略
- VB的API编程精粹(2)
- vb编程:windwosapi全攻略
- VB编程:WindwosAPI全攻略
- VB的API编程精粹(二)
- VB的API编程精粹
- VB的API编程精粹(一)
- VB的API编程精粹(一)
- VB编程:WindwosAPI全攻略
- VB的API编程精粹(1)