16,553
社区成员
发帖
与我相关
我的任务
分享
Public Class Form1
Dim path, path1 As New System.Drawing.Drawing2D.GraphicsPath
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim p0 As New Point(50, 50)
Dim p1 As New Point(200, 200)
Dim p2 As New Point(200, 201)
Dim p3 As New Point(50, 51)
path1.AddLines(New Point() {p0, p1, p2, p3, p0})
path.AddLine(p0, p1)
End Sub
'根据鼠标的位置取一个5X5的正方形
Function getRoundRec(ByVal p As Point) As Rectangle
Return New Rectangle(p.X, p.Y, 5, 5)
End Function
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
If New Region(path1).IsVisible(getRoundRec(e.Location)) Then
MsgBox("the click event ")
End If
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.DrawPath(Pens.Black, path)
End Sub