zoukankan      html  css  js  c++  java
  • VB API 之 第十课 图像编程(三)

      首先绘制多边形的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则表示成功

    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
  • 相关阅读:
    22_selenium_使用cookie直接登录
    21_无头模式
    自动化测试-设计模式-介绍
    Doorls
    pytest-Allure报告
    pytest-架构1
    pytest-第一次学习梳理
    web测试
    测试-工时评估
    封装pyuic5转换ui文件的脚本
  • 原文地址:https://www.cnblogs.com/delphi2014/p/4029514.html
Copyright © 2011-2022 走看看