title image


Smiley Re: Drag & Drop in einer Listview ??? VB6
Das hier ist aus einem PM3-Player den ich ma gebaut habe:

Private Sub lstPlaylist_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)

If Data.GetFormat(vbCFText) Then

If Left(Data.GetData(vbCFText), 5) "blaaa" Then Exit Sub



Dim oItem As ListItem

Dim nIndex As Integer

Dim qIndex As Integer

Dim qKey As String

Dim qText As String

Dim qFarbe As Long



Set oItem = lstPlaylist.HitTest(x, y)

If oItem Is Nothing Then Exit Sub

nIndex = oItem.Index



qIndex = Mid(Data.GetData(vbCFText), 6)

qKey = lstPlaylist.ListItems.Item(qIndex).Key

qText = lstPlaylist.ListItems.Item(qIndex).Text

qFarbe = lstPlaylist.ListItems.Item(qIndex).ForeColor



lstPlaylist.ListItems.Remove (qIndex)

lstPlaylist.ListItems.Add nIndex, qKey, qText

lstPlaylist.ListItems(nIndex).SubItems(1) = DieSongs(Mid(qKey, 3)).Laenge

lstPlaylist.ListItems.Item(nIndex).ForeColor = qFarbe

End If

End Sub



Private Sub lstPlaylist_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)

Data.SetData "blaaa" & lstPlaylist.SelectedItem.Index

DataFormat = vbCFText

End Sub



Und wenn du noch scrollen willst während du Dropst dann kannst du noch folgendes dazufügen:



Private Sub lstPlaylist_OLEDragOver(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer) 'Scroll bei Drag & Drop

Dim fIndex As Long



If Titelanzahl = 0 Then Exit Sub 'Titelanzahl ist die Anzahl der Elemente in der Liste



If y < 230 Then

fIndex = CInt(lstPlaylist.GetFirstVisible.Index - 1)

If fIndex < 1 Then Exit Sub

lstPlaylist.ListItems.Item(fIndex).EnsureVisible

ElseIf y > lstPlaylist.Height - 150 Then

fIndex = CInt(lstPlaylist.GetFirstVisible.Index + lstPlaylist.Height / 230 + 1)

If fIndex > Titelanzahl Then Exit Sub

lstPlaylist.ListItems.Item(fIndex).EnsureVisible

End If

End Sub
MfG Buhmann

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: