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 PointPrivate Sub Command1_Click() Dim hbrush As Long Dim hrgn As Long Dim intP As Integer
照片在这里
http://hi.csdn.net/space-8409715-do-album-picid-864917.html
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 PointPrivate 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 SubPrivate 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