Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function Polygon Lib "gdi32.dll" _
(ByVal hdc As Long, lpPoints As Any, ByVal cPoints As Long) As Long
Private Sub Form_Load()
Me.Picture1.ScaleMode = 3
Me.Picture1.BackColor = vbWhite
End Sub
Private Sub Picture1_Paint()
Dim lpPoints(4) As POINTAPI
Dim dx, dy
dx = Me.Picture1.ScaleWidth - 20
dy = Me.Picture1.ScaleHeight - 20
Me.Picture1.ForeColor = vbRed
Randomize
lpPoints(0).x = dx / 2 + 10: lpPoints(0).y = 10
lpPoints(1).x = dx / 3 + 10: lpPoints(1).y = dy - 10
lpPoints(2).x = dx - 10: lpPoints(2).y = dy / 3 + 10
lpPoints(3).x = 10: lpPoints(3).y = lpPoints(2).y
lpPoints(4).x = dx / 3 * 2 + 10: lpPoints(4).y = lpPoints(1).y
Call Polygon(Me.Picture1.hdc, lpPoints(0), 5)
End Sub |