-
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
-
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.