|
-
Aug 29th, 2007, 12:21 AM
#1
Thread Starter
Fanatic Member
Drag Small Images on Form
Hello
I want to Grag small images (Shortcuts) on my form like windows desktop. Please help me
Farooq
-
Aug 29th, 2007, 12:36 AM
#2
Re: Drag Small Images on Form
What cntrols are you using? A Listview will make it look just like Windows desktop.
-
Aug 29th, 2007, 02:26 AM
#3
Thread Starter
Fanatic Member
Re: Drag Small Images on Form
I m using Image Control... I m trying to make my project main screen like windows XP main desktop
-
Aug 29th, 2007, 02:36 AM
#4
Re: Drag Small Images on Form
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:
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
Then you can move each item with the Mouse, like in desktop.
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
Last edited by jcis; Aug 29th, 2007 at 06:19 AM.
-
Aug 29th, 2007, 11:37 AM
#5
Addicted Member
Re: Drag Small Images on Form
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 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.*
Do not use if shrinkwrap is broken or missing!
I'm learning how to fish, too!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|