'Circular Hitbox in Visual Basic WinForm

How can I change the hitbox of a PictureBox where the image is circular? By hitbox, I mean where the ClickEvent registers.



Solution 1:[1]

If you want a circle in the middle (instead of an oval), then use something like:

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Idle_Mind