Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Click()
Dim pt(2) As POINTAPI
pt(0).x = 200: pt(0).y = 200
pt(1).x = 300: pt(1).y = 300
pt(2).x = 100: pt(2).y = 300
hpen = CreatePen(0, 1, 边框颜色) '创建画笔
SelectObject Me.hdc, hpen '使用画笔
hbrush = CreateSolidBrush(填充颜色) '创建笔刷
SelectObject Me.hdc, hbrush '使用笔刷
Polygon Me.hdc, pt(0), 3 '绘制并填充多边形
DeleteObject hpen '删除画笔和笔刷
DeleteObject hbrush
End Sub