Results 1 to 2 of 2

Thread: Help With List / Listbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    7

    Question

    If Anyone reading this has Winamp, then you will know what I am talking about. In Winamp, in the listbox where all your songs are, you can drag a file up and it will change the order.. Anyone know how to do it?

    ex:
    01. artist1
    02. artist2
    03. artist3
    and i drag 03. to number. 1 and 2 move down and 3 becomes 1 and the numbering order changes too
    so it will say
    01. artist3
    02. artist1
    03. artist2

    anyone know how to do it, or if there is a special OCX or DLL.

    Thanks

    -latino
    Sub Latino()
    Dim Latino99 As ClsLatino
    Latino99.FileName = "C:\latino"
    Latino99.Open
    Latino99.Play
    Latino99.Scroll "Latino's Audio Player"
    End Sub

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Sure thing.

    Code:
    Private Type POINTAPI
       X As Long
       Y As Long
    End Type
    Private Declare Function LBItemFromPt Lib "comctl32.dll" (ByVal hwnd As Long, ByVal ptx As Long, ByVal pty As Long, ByVal bAutoScroll As Long) As Long
    Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    
    Private Sub List1_DragDrop(Source As Control, X As Single, Y As Single)
        Dim intCurItem As Long
        Dim pt As POINTAPI
        Dim strItem As String
        
        
        pt.X = X \ Screen.TwipsPerPixelX
        pt.Y = Y \ Screen.TwipsPerPixelY
        Call ClientToScreen(List1.hwnd, pt)
        intCurItem = LBItemFromPt(List1.hwnd, pt.X, pt.Y, False)
        If intCurItem > -1 Then
            strItem = List1.List(List1.ListIndex)
            List1.RemoveItem List1.ListIndex
            List1.AddItem strItem, intCurItem
        End If
    End Sub
    
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            List1.Drag vbBeginDrag
        End If
    End Sub
    Make sure you set the DragIcon property to the apropriate cursor.

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