Option Explicit
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function FillRgn Lib "gdi32.dll" (ByVal hDC As Long, ByVal hRgn As Long, ByVal hbrush 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 Type POINTAPI
X As Long
Y As Long
End Type
Dim tochka(5) As POINTAPI
Dim hbrush As Long
Dim hRgn As Long
Dim color As Long
Dim vhojdenie As Long
Private Sub Segment_1()
tochka(0).X = ScaleWidth * 0.13
tochka(1).X = ScaleWidth * 0.87
tochka(2).X = ScaleWidth * 0.92
tochka(3).X = ScaleWidth * 0.87
tochka(4).X = ScaleWidth * 0.13
tochka(5).X = ScaleWidth * 0.08
tochka(0).Y = ScaleHeight * 0.03
tochka(1).Y = ScaleHeight * 0.03
tochka(2).Y = ScaleHeight * 0.065
tochka(3).Y = ScaleHeight * 0.1
tochka(4).Y = ScaleHeight * 0.1
tochka(5).Y = ScaleHeight * 0.065
hRgn = CreatePolygonRgn(tochka(0), 6, 1)
hbrush = CreateSolidBrush(vbRed)
FillRgn hDC, hRgn, hbrush
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, myX As Single, myY As Single)
vhojdenie = PtInRegion(hRgn, myX, myY)
If vhojdenie <> 0 Then
tochka(0).X = ScaleWidth * 0.13
tochka(1).X = ScaleWidth * 0.87
tochka(2).X = ScaleWidth * 0.92
tochka(3).X = ScaleWidth * 0.87
tochka(4).X = ScaleWidth * 0.13
tochka(5).X = ScaleWidth * 0.08
tochka(0).Y = ScaleHeight * 0.03
tochka(1).Y = ScaleHeight * 0.03
tochka(2).Y = ScaleHeight * 0.065
tochka(3).Y = ScaleHeight * 0.1
tochka(4).Y = ScaleHeight * 0.1
tochka(5).Y = ScaleHeight * 0.065
hRgn = CreatePolygonRgn(tochka(0), 6, 1)
hbrush = CreateSolidBrush(vbBlue)
FillRgn hDC, hRgn, hbrush
End If
End Sub
Private Sub UserControl_Resize()
AutoRedraw = True
ScaleMode = 3
Cls
Segment_1
End Sub