尝试类似...
Public Class Form1
Private InTarget As Boolean = False
Private Target As New Rectangle(New Point(87, 5), New Size(45, 51))
Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
Dim clientCoords As Point = PictureBox1.PointToClient(Cursor.Position)
InTarget = Target.Contains(clientCoords)
Label1.Text = IIf(InTarget, "coordinate correct", "")
PictureBox1.Refresh()
End Sub
Private Sub PictureBox1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If InTarget Then
Using highlight As New SolidBrush(Color.FromArgb(128, Color.Yellow)) ' 0 to 255
e.Graphics.FillRectangle(highlight, Target)
End Using
End If
End Sub
End Class