Beastsouls
Messages postés15Date d'inscriptionlundi 28 octobre 2013StatutMembreDernière intervention21 mars 2016
-
Modifié par crapoulou le 16/03/2015 à 11:05
Bonjour,
Je possède deux labels de même taille tout les deux positionnés dans une picturebox. J'arrive à déplacer ces deux labels à volonté sur ma pictureBox, maintenant, ce que j'aimerais faire et que je n'arrive pas est:
Dès qu'un de mes labels touche un endroit d'un autre label ( quelque soit cet endroit), je voudrais le bloquer de manière à ce qu'il ne puisse pas passer au travers de l'autre label.
Voici mon code actuel:
Public Sub collision(ByRef ctl As Control, ByVal e As MouseEventArgs)
For Each c As Control In pic_MAQUETTE.Controls
If Not ctl.Equals(c) Then
If ctl.Bounds.IntersectsWith(c.Bounds) Then
If (ctl.Top >= c.Top + c.Height And ctl.Left <= c.Left + c.Width
And ctl.Left + ctl.Width >= c.Left) Or (ctl.Top + ctl.Height =
c.Top And ctl.Left <= c.Left + c.Width And ctl.Left +
ctl.Width >= c.Left) Then
ctl.Location = New Point(ctl.Left, c.Location.Y)
End If
If (ctl.Left + ctl.Width <= c.Left And ctl.Top >= c.Top + c.Height
And ctl.Top + ctl.Height <= c.Top) Or (ctl.Left = c.Left +
c.Width And ctl.Top >= c.Top + c.Height And ctl.Top +
ctl.Height <= c.Top) Then
ctl.Location = New Point(c.Location.X, ctl.Location.Y)
End If
End If
End If
Next
End Sub