第1个回答 2012-04-18
Const ALTERNATE = 1
Const WINDING = 2
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y 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 CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Dim hRegion As Long
Dim hBrush As Long
Dim pic1 As New StdPicture
Private Sub Command1_Click()
Call FillRgn(Me.hdc, hRegion, hBrush)
End Sub
Private Sub Form_Load()
Dim p(8) As POINTAPI
Me.ScaleMode = 3
p(0).X = 100: p(0).Y = 100
p(1).X = 150: p(1).Y = 70
p(2).X = 110: p(2).Y = 70
p(3).X = 110: p(3).Y = 30
p(4).X = 50: p(4).Y = 30
p(5).X = 50: p(5).Y = 70
p(6).X = 30: p(6).Y = 70
p(7).X = 30: p(7).Y = 85
p(8).X = 85: p(8).Y = 85
hRegion = CreatePolygonRgn(p(0), 9, ALTERNATE)
hBrush = CreateSolidBrush(RGB(255, 0, 0))
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If PtInRegion(hRegion, X, Y) Then
Debug.Print "In 在多边形区域"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteObject hRegion
DeleteObject hBrush
End Sub本回答被提问者采纳