1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
Private Type COORD
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 = 2
Const WINDING = 2
Const BLACKBRUSH = 4
Private Sub Form_Paint()
Dim poly(1 To 5) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
Me.Cls
NumCoords = 5
Me.ScaleMode = vbPixels
poly(1).x = Form1.ScaleWidth / 2
poly(1).y = Form1.ScaleHeight / 2
poly(2).x = 2 * Form1.ScaleWidth / 3
poly(2).y = 3 * Form1.ScaleHeight / 4
poly(3).x = 1 * Form1.ScaleWidth / 3
poly(3).y = 3 * Form1.ScaleHeight / 4
poly(4).x = 2 * Form1.ScaleWidth / 3
poly(4).y = 1 * Form1.ScaleHeight / 4
poly(5).x = 1 * Form1.ScaleWidth / 3
poly(5).y = 1 * Form1.ScaleHeight / 4
Polygon Me.hdc, poly(1), NumCoords
hBrush = GetStockObject(BLACKBRUSH)
hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
If hRgn Then FillRgn Me.hdc, hRgn, hBrush
DeleteObject hRgn
End Sub
Private Sub Form_Resize()
Form_Paint
End Sub |
Partager