如何更改影像為圓形的 PictureBox 的命中框?通過 hitbox,我的意思是 ClickEvent 注冊的位置。
uj5u.com熱心網友回復:
您可以使用 Control.Region 屬性來創建使用圓形 GraphicsPath 的區域。此區域用于 Click 事件以及 MouseEnter、MouseHover 和 MouseLeave 事件。
圖片框示例:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim path As New Drawing2D.GraphicsPath()
path.AddArc(0, 0, PictureBox1.Width, PictureBox1.Height, 0, 360) 'A circle at 0,0 relative to the PictureBox, sharing its Width and Height
PictureBox1.Region = New Region(path)
End Sub
uj5u.com熱心網友回復:
如果你想在中間有一個圓圈(而不是橢圓),那么使用類似的東西:
Dim path As New Drawing2D.GraphicsPath()
Dim radius As Integer = Math.Min(PictureBox1.Width - 1, PictureBox1.Height - 1) / 2
Dim rc As New Rectangle(New Point(PictureBox1.Width / 2, PictureBox1.Height / 2), New Size(1, 1))
rc.Inflate(radius, radius)
path.AddEllipse(rc)
PictureBox1.Region = New Region(path)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/442643.html
標籤:VB.net
上一篇:VB.NET-如何將控制元件名稱與另一個變數值連接以更改其屬性?
下一篇:合并兩個大檔案
