码迷,mamicode.com
首页 > Windows程序 > 详细

VB API 之 第十课 图像编程(三)

时间:2014-10-16 21:18:33      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

  首先绘制多边形的API函数有:

  Polygon();   //描绘一个多边形,由两点或三点的任意系列构成

  polyPolygon();   //用当前选定的画笔绘画两个或多个多边形

  PolyPolyline();   //用当前选定的画笔描绘两个或多个多边形

  首先来看Polygon的函数原型

Private Declare Function Polygon Lib "gdi32" Alias "Polygon" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long

  参数说明

  hdc: Long  // 绘制多边形设备的句柄

  lpPoint  //指向一个POINTAPI类型的数组

  nCount:Long  //多边形的顶点数

  返回Long类型值,返回0表示失败,不为0则表示成功

bubuko.com,布布扣

Option Explicit

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Dim Pos(5) As POINTAPI
Dim Flag As Boolean
Dim i As Integer
绘图标志变量
Private Sub Command1_Click() Flag = True 开始绘图 End Sub
Private Sub Command2_Click() Flag
= False 结束绘图 End Sub
Private Sub Form_Load() Flag
= 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 Flag Then Pos(i).x
= x Pos(i).y = y If (i >= 3) Then Polygon Me.Picture1.hdc, Pos(0), 4 将多边形的边数设置为4 ‘你也可以自己修改多边形的边数 Me.Picture1.Circle (x, y), 3 i = 0 Exit Sub End If End If 绘制多边形 If (i <= 3) Then i = i + 1 Me.Picture1.Circle (x, y), 3 End If End Sub

 

VB API 之 第十课 图像编程(三)

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/delphi2014/p/4029514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!