7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Type Point
x As Long
y As Long
End Type
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hrgn As Long, ByVal hbrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Const ALTERNATE = 1 ' ALTERNATE and WINDING are
Const WINDING = 2 ' constants for FillMode.
Const BLACKBRUSH = 4 ' Constant for brush type.
Private Const GRAY_BRUSH = 2
Private A(0 To 12) As Point
Private Sub Command1_Click()
Dim hbrush As Long
Dim hrgn As Long
Dim intP As Integer
Polygon Picture1.hdc, A(0), 13
hbrush = GetStockObject(GRAY_BRUSH)
hrgn = CreatePolygonRgn(A(0), 13, ALTERNATE)
If hrgn Then FillRgn Picture1.hdc, hrgn, hbrush
DeleteObject hrgn
Picture1.DrawWidth = 5
For intP = 0 To 9
Picture1.Line (A(intP).x, A(intP).y)-(A(intP + 1).x, A(intP + 1).y), vbBlue
Next intP
End Sub
Private Sub Form_Load()
Dim intP As Integer
For intP = 0 To 10
A(intP).x = intP * 60
A(intP).y = 300 - CInt(300 * Rnd)
Next intP
A(11).x = 600
A(11).y = 300
A(12).x = 0
A(12).y = 300
Me.ScaleMode = 3
Picture1.ScaleMode = 3
End Sub