Dim gpath1 As New System.Drawing.Drawing2D.GraphicsPath
Dim gpath2 As New System.Drawing.Drawing2D.GraphicsPath
Dim Region1 As System.Drawing.Region
Dim Region2 As System.Drawing.Region
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
gpath1.AddRectangle(New Rectangle(10, 10, 25, 20))
gpath1.AddEllipse(New Rectangle(20, 20, 30, 20))
gpath1.AddPolygon(New PointF() {New PointF(30, 30), New PointF(40, 30), New PointF(60, 60), New PointF(60, 45), New PointF(30, 40)})
gpath2.AddRectangle(New Rectangle(10, 50, 30, 20))
Region1 = New System.Drawing.Region(gpath1)
Region2 = New System.Drawing.Region(gpath2)
End Sub
Private Sub Form_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If Region1.IsVisible(e.X, e.Y) Then
MessageBox.Show("Rojo")
End If
If Region2.IsVisible(e.X, e.Y) Then
MessageBox.Show("Azul")
End If
End Sub
Private Sub Form_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.FillPath(Brushes.Red, gpath1) 'Esto se puede omitir, es solo para mostrar la region.
e.Graphics.FillPath(Brushes.Blue, gpath2) 'Esto se puede omitir, es solo para mostrar la region.
End Sub