Public Declare Function PtInRegion Lib "gdi32" Alias "PtInRegion" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long确定点是否在指定区域内~~
'函数CheckPointInPolygon返回值不为零,就是在多边形内 Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As LongPrivate Type POINTAPI X As Long Y As Long End TypePrivate Function CheckPointInPolygon(arr() As POINTAPI, tP As POINTAPI) As Long Dim lRgn As Long lRgn = CreatePolygonRgn(arr(0), UBound(arr) + 1, 1) CheckPointInPolygon = PtInRegion(lRgn, tP.X, tP.Y) End FunctionPrivate Sub Form_Load() Dim tArrPoint(3) As POINTAPI Dim tP As POINTAPI
tArrPoint(0).X = 0 tArrPoint(0).Y = 0
tArrPoint(1).X = 300 tArrPoint(1).Y = 100
tArrPoint(2).X = 100 tArrPoint(2).Y = 300
tArrPoint(3).X = 0 tArrPoint(3).Y = 0
tP.X = 10 tP.Y = 10 MsgBox CheckPointInPolygon(tArrPoint, tP) End Sub Dim tArrPoint(3) As POINTAPIPrivate Function CheckPointInPolygon(arr() As POINTAPI,tP As POINTAPI) Dim lRgn As Long lRgn=CreatePolygonRgn( End Function
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As LongPrivate Type POINTAPI
X As Long
Y As Long
End TypePrivate Function CheckPointInPolygon(arr() As POINTAPI, tP As POINTAPI) As Long
Dim lRgn As Long
lRgn = CreatePolygonRgn(arr(0), UBound(arr) + 1, 1)
CheckPointInPolygon = PtInRegion(lRgn, tP.X, tP.Y)
End FunctionPrivate Sub Form_Load()
Dim tArrPoint(3) As POINTAPI
Dim tP As POINTAPI
tArrPoint(0).X = 0
tArrPoint(0).Y = 0
tArrPoint(1).X = 300
tArrPoint(1).Y = 100
tArrPoint(2).X = 100
tArrPoint(2).Y = 300
tArrPoint(3).X = 0
tArrPoint(3).Y = 0
tP.X = 10
tP.Y = 10
MsgBox CheckPointInPolygon(tArrPoint, tP)
End Sub
Dim tArrPoint(3) As POINTAPIPrivate Function CheckPointInPolygon(arr() As POINTAPI,tP As POINTAPI)
Dim lRgn As Long
lRgn=CreatePolygonRgn(
End Function