Results 1 to 5 of 5

Thread: Drag Small Images on Form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Drag Small Images on Form

    Hello

    I want to Grag small images (Shortcuts) on my form like windows desktop. Please help me

    Farooq

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Drag Small Images on Form

    What cntrols are you using? A Listview will make it look just like Windows desktop.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    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

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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.

  5. #5
    Addicted Member kewakl's Avatar
    Join Date
    Oct 2006
    Location
    between keyboard and chair
    Posts
    220

    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
  •  



Click Here to Expand Forum to Full Width