Hello
I want to Grag small images (Shortcuts) on my form like windows desktop. Please help me
Farooq
Printable View
Hello
I want to Grag small images (Shortcuts) on my form like windows desktop. Please help me
Farooq
What cntrols are you using? A Listview will make it look just like Windows desktop.
I m using Image Control... I m trying to make my project main screen like windows XP main desktop
Using a Listview you need to add also an ImageList, load your images there (should be 32x32 images) and add the items to the ListView like this:
Then you can move each item with the Mouse, like in desktop.Code:With ListView1
.Icons = Me.ImageList1 'This can be done in the properties window
.ListItems.Add , , "Text here", 1
.ListItems.Add , , "Text here", 2
.ListItems.Add , , "Text here", 3
End With
But if you still want to use the Image Control, the movement can be accomplished by adding some code to the Mouse_Move event. And it would be better to use a Control Array of Image Controls, this way only 1 Event will handle all the Image Controls in the array. The event should be:
Code:Private Sub Image1_MouseMove(Index As Integer, Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Static lX As Single, lY As Single
With Image1.Item(Index)
If Button = 0 Then
lX = X
lY = Y
ElseIf Button = vbLeftButton Then
.Move .Left + X - lX, .Top + Y - lY
End If
End With
End Sub
you will need some sanity check on the drop location of your images.
With this method, you can drag the images way outside the form's view
and lose :eek: them -- ( I do not know the size of your form!)
If you were using a Windowed Control like the PictureBox,
you could use SendMessage and ReleaseCapture to move the controls.
The position sanity check is *built-in.*