1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Private Sub Annonce_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Defini les objets déplaçable
SetMoveable(LabTextParam)
SetMoveable(LabOnAppel)
SetMoveable(LabNomInterprete)
SetMoveable(LabTitre)
SetMoveable(LabNomTitre)
End Sub
Dim depart As Point
Dim deplacement As Boolean = False
Private Sub SetMoveable(ByRef ctl As Control)
AddHandler ctl.MouseDown, AddressOf Generic_MouseDown
AddHandler ctl.MouseMove, AddressOf Generic_MouseMove
AddHandler ctl.MouseUp, AddressOf Generic_MouseUp
End Sub
Private Sub Generic_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
'Mémorisation du point de départ
depart = e.Location
deplacement = True
End Sub
Private Sub Generic_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If deplacement Then
Dim bt As Control = DirectCast(sender, Control)
Dim loc As Point
loc.X = bt.Location.X + e.Location.X - depart.X
loc.Y = bt.Location.Y + e.Location.Y - depart.Y
'Chargement de la nouvelle position du control
bt.Location = loc
End If
End Sub
Private Sub Generic_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
deplacement = False
End Sub |
Partager