VB API 之 第九課 映像編程(二)

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   for   sp   

用到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個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.