Vb.net PictureBox-给定坐标内的不透明度绘制
我有一个Picturebox,里面我想画一个给定坐标的确定区域(不透明度不完全隐藏绘制区域) 到目前为止,当用户单击picturebox时,我得到了“IF”语句,它检查是否是具有正确坐标的区域:Vb.net PictureBox-给定坐标内的不透明度绘制,vb.net,paint,picturebox,Vb.net,Paint,Picturebox,我有一个Picturebox,里面我想画一个给定坐标的确定区域(不透明度不完全隐藏绘制区域) 到目前为止,当用户单击picturebox时,我得到了“IF”语句,它检查是否是具有正确坐标的区域: If LocalMousePosition.X >= 87 And LocalMousePosition.X <= 131 And LocalMousePosition.Y >= 5 And LocalMousePosition.Y <= 55 Then
If LocalMousePosition.X >= 87 And LocalMousePosition.X <= 131 And LocalMousePosition.Y >= 5 And LocalMousePosition.Y <= 55 Then
Label1.Text = "coordinate correct"
Else
Label1.Text = ""
End If
如果LocalMousePosition.X>=87且LocalMousePosition.X=5且LocalMousePosition.Y请尝试以下操作
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
哇,你真是个天才,你又帮我找到了解决办法!你在这个问题上也帮了我,非常感谢!那很好。别担心。我不记得你在什么声誉级别可以做特定的事情。