10-09-20, 05:03 PM
(آخر تعديل لهذه المشاركة : 10-09-20, 05:04 PM {2} بواسطة عبد الهادي بهاب.)
اضافة متميزة للاستاذ انس حفظه الله
Anas Mahmoud
تفضل اخي الكريم :
اضفت الاكواد التالية الى مشروعك بعد اذنك بدلا من حدث الضغط على الصور :
واضفت ايضا في الفورم لود :
الملف بعد التعديل
http://vb4arb.com/vb/attachment.php?aid=25643
Anas Mahmoud
تفضل اخي الكريم :
اضفت الاكواد التالية الى مشروعك بعد اذنك بدلا من حدث الضغط على الصور :
PHP كود :
Dim movingPicOriginalLeft As Integer
Dim movingPic As PictureBox
PHP كود :
Dim mX As Integer
Private Sub PictureBox9_MouseDown(sender As Object, e As MouseEventArgs)
Dim pic As PictureBox = sender
pic.BringToFront()
movingPic = pic
movingPicOriginalLeft = pic.Left
mX = e.X
End Sub
Private Sub PictureBox9_MouseMove(sender As Object, e As MouseEventArgs)
Dim pic As PictureBox = sender
If pic Is movingPic Then
pic.Left += e.X - mX
End If
End Sub
Private Sub PictureBox9_MouseUp(sender As Object, e As MouseEventArgs)
Dim pic As PictureBox = sender
Dim OverlappingPic As PictureBox = GetOvelapping(pic)
RestoreLocation()
If Not OverlappingPic Is Nothing Then
SwapPicture(pic, OverlappingPic)
End If
End Sub
Function GetOvelapping(picturebox As PictureBox) As PictureBox
For Each pic In Pict
If pic.Visible = False Then Continue For
If pic Is picturebox Then Continue For
If IsOverlapping(pic, picturebox) Then Return pic
Next
Return Nothing
End Function
Function IsOverlapping(pic1 As PictureBox, pic2 As PictureBox) As Boolean
Return ((pic1.Left + pic1.Width) > pic2.Left) And
((pic1.Left) < pic2.Left + pic2.Width)
End Function
Sub SwapPicture(pic1 As PictureBox, pic2 As PictureBox)
Dim tmpLeft As Integer
tmpLeft = pic1.Left
pic1.Left = pic2.Left
pic2.Left = tmpLeft
End Sub
Sub RestoreLocation()
If movingPic Is Nothing Then Return
movingPic.Left = movingPicOriginalLeft
movingPic = Nothing
movingPicOriginalLeft = Nothing
mX = Nothing
End Sub
واضفت ايضا في الفورم لود :
PHP كود :
For Each pic In Pict
AddHandler pic.MouseDown, AddressOf PictureBox9_MouseDown
AddHandler pic.MouseUp, AddressOf PictureBox9_MouseUp
AddHandler pic.MouseMove, AddressOf PictureBox9_MouseMove
Next
الملف بعد التعديل
http://vb4arb.com/vb/attachment.php?aid=25643
لعل الكلمة التي تنفعني لم أكتبها بعد
عبد الله بن المبارك

