Banner

Rendere cliccabile una figura geometrica

Volete che un'area dello schermo o di un disegno di una PictureBox sia sensibile al click del mouse? Potete fare qualcosa di simile:

Public Class Form1

    Dim myPath As New Drawing2D.GraphicsPath

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        myPath.StartFigure()
        myPath.AddEllipse(20, 30, 50, 35)
        myPath.CloseFigure()

    End Sub

    Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As  _
                                       System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick

        If myPath.IsVisible(PictureBox1.PointToClient(MousePosition)) Then MessageBox.Show("Click")

    End Sub

    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As  _
                                      System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

        If myPath.IsVisible(PictureBox1.PointToClient(MousePosition)) Then MessageBox.Show("Click")

    End Sub

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _
    Handles PictureBox1.Paint

        e.Graphics.FillEllipse(Brushes.Blue, 20, 30, 50, 35)

    End Sub

End Class
Siti Ufficiali Editor Free Guide Online Utility
Microsoft Visual Studio MSDN InnoSetup
Apple XCode Documentazione .Net Cyber Installer
Oracle NetBeans Apple Developer NSIS
Debian Eclipse W3C Diagram Online
Distrowatch Bluefish W3C Validator Junior Icon Editor
Brackets W3Schools Edit Cursors Online
TextWrangler

Sito realizzato da Fiaschi Francesco - Aggiornamento Dicembre 2018

W3C - XHTML 1.1 Validated