Private pointDown As Point Private Sub Mouse_Down(ByVal e As System.Windows.Forms.MouseEventArgs) If e.Button = MouseButtons.Left Then 'recupere position du click pointDown = e.Location TextBox1.Text = pointDown.ToString End If End Sub Private Sub PictureBallon1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBallon1.MouseDown Mouse_Down(e) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionImports System.Threading Public Class Form1 Private pointDown As Point Private isMouseDown As Boolean = False Private Sub Mouse_Down(ByVal e As System.Windows.Forms.MouseEventArgs) If e.Button = MouseButtons.Left Then 'recupere position du click pointDown = e.Location TextBox1.Text = pointDown.ToString isMouseDown = True End If End Sub Private Sub Mouse_Move(ByVal e As System.Windows.Forms.MouseEventArgs) If isMouseDown Then 'deplacement active oui? Dim pointMove As Point = e.Location 'le deplacement relatif deltaPoint = pointMove - pointDown 'ajouter à Location actuelle End If End Sub Dim PointPanier As Integer = 0 Dim deltaPoint As Point Private Sub PictureBallon1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBallon1.MouseMove Mouse_Move(e) Dim _Send As Object = sender _Send.Location = _Send.Location + deltaPoint End Sub Private Sub Mouse_Up(ByVal e As System.Windows.Forms.MouseEventArgs) If e.Button = MouseButtons.Left Then 'desactive deplacement isMouseDown = False End If deltaPoint = Nothing End Sub Private Sub PictureBallon1_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBallon1.MouseUp Mouse_Up(e) Dim _Send As Object = sender If (_Send.Location.X + 30 > 50 AndAlso _Send.Location.Y + 30 > 0) And (_Send.Location.X + 30 < 100 AndAlso _Send.Location.Y + 30 < 75) Then PointPanier += 1 Label1.Text = "PANIER :" & PointPanier.ToString End If Dim decenteBallon As New Point decenteBallon.X = 0 decenteBallon.Y = 10 Do Until _Send.Location.Y >= 200 _Send.Location = _Send.Location + decenteBallon Thread.Sleep(50) _Send.Refresh() Loop decenteBallon.X = _Send.Location.X decenteBallon.Y = 200 _Send.Location = decenteBallon End Sub Private Sub PictureBallon1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBallon1.MouseDown Mouse_Down(e) End Sub End Class
5 mars 2019 à 12:55