Sollte jetzt auch mit XProfan11 funktionieren.
Code
$H Windows.ph
$H Messages.ph
$H commctrl.ph
DEF &LVM_SETINSERTMARK 4262
DEF &LVM_SETINSERTMARKCOLOR 4266
Struct LVINSERTMARK = cbSize&,dwFlags&,iItem&,dwReserved&
DEF &DL_BEGINDRAG 1157
DEF &DL_DRAGGING 1158
DEF &DL_DROPPED 1159
DEF &DL_MOVECURSOR 3
DEF &DL_COPYCURSOR 2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Struct LVHitTestInfo = X&,Y&,flags&,Item&,SubItem&
Declare LVHTI#,l%,L.SubItem$
Dim LVHTI#,LVHitTestInfo
Proc LV_HitTest
Parameters LV&,X%,Y%
~GetCursorPos(LVHTI#)
~ScreenToClient(LV&,LVHTI#)
SendMessage(LV&,~LVM_SUBITEMHITTEST,0,LVHTI#)
Return LVHTI#.SubItem&
EndProc
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Proc LvDeSelect'deselectieren
Parameters Lv&,Item&
Declare s#
Dim s#,1024
LONG s#,12=0
LONG s#,16=~LVIS_SELECTED | ~LVIS_FOCUSED
sendmessage(Lv&,~LVM_SETITEMSTATE,Item&,s#)
dispose s#
EndProc
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Proc LvSelect'selectieren
Parameters Lv&,Item&
Declare s#
Dim s#,1024
LONG s#,12=$2
LONG s#,16=~LVIS_SELECTED | ~LVIS_FOCUSED
sendmessage(Lv&,~LVM_SETITEMSTATE,Item&,s#)
sendmessage(lv&,~LVM_SETHOTITEM ,item&,0)
sendmessage(lv&,~LVM_ENSUREVISIBLE ,Item&,0)
dispose s#
EndProc
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Struct POINT = X&,Y&
Struct DRAGLISTINFO = uNotification&,hWnd&,ptCursor!POINT
Var FirstItem& = 0
Var LastItem& = 0
Var MoveString$ = ""
Var MoveCursor& = ~LoadCursor(~GetModuleHandle("shell32.dll"),1003)
'Genau diese spezielle Meldung muss registiert werden
'damit das Fenster die Drag&Drop Operationen verarbeiten kann.
Var DragMSG& = ~RegisterWindowMessage("commctrl_DragListMsg")
CLS
SetDialogFont ~GetStockObject(~ANSI_VAR_FONT)
Var Ende& = 0
Var dlg& = @Create("ChildWindow", %hwnd, "Liste", 80, 60,300,300)
Var Text$ = "Name;0;140"
Var draglist& = Create("GridBox", dlg&, text$, 0, 80, 14, 100, 220)
'Die Listbox für Drag&Drop vobereiten
External("comctl32.dll","MakeDragList",Draglist&)
Addstring(Draglist&,"Eintrag")
Addstring(Draglist&,"Auftrag")
Addstring(Draglist&,"Anton")
Addstring(Draglist&,"Otto")
Addstring(Draglist&,"Werner")
Addstring(Draglist&,"Karl")
SubClass dlg&,1
WhileNot Ende&
Waitinput
EndWhile
SubClass dlg&,0
End
SubClassProc
If SubClassMessage(dlg&,DragMSG&)
Var structInsertMark# = New(LVINSERTMARK)
structInsertMark#.cbSize& = 16
structInsertMark#.dwFlags& = 1 'LVIM_AFTER
structInsertMark#.dwReserved& = 0
Var Info# = New(DRAGLISTINFO)
locate 0,0
l% = LV_HitTest(Draglist&,%mousex,%mousey)
L.SubItem$=GetText$(Draglist&,LVHTI#.Item&,LVHTI#.SubItem&)
Info# = &slParam
If Info#.uNotification& = &DL_BEGINDRAG'Drag&Drop beginnt und Item merken
FirstItem& = LVHTI#.Item&
print FirstItem&, " nach "
'Marker zeichnen, muss nicht sein, erhöht aber die Sichtbarkeit
structInsertMark#.iItem& = -1
Sendmessage(draglist&,&LVM_SETINSERTMARKCOLOR,0,$008000)
SendMessage(Draglist&, &LVM_SETINSERTMARK, 0,structInsertMark#)
MoveString$ = GetText$(Draglist&,LVHTI#.Item&,LVHTI#.SubItem&)'Item-Text merken
Set("WinProc", 0)
~SetCursor(MoveCursor&)
Return &DL_COPYCURSOR
ElseIf Info#.uNotification& = &DL_DRAGGING'Drag&Drop ist im Gange
LastItem& = LVHTI#.Item&
locate 0,10
Print " "
locate 0,10
Print LastItem&
LvSelect Draglist&,LastItem&
'Marker neuzeichnen
structInsertMark#.iItem& = LastItem&
SendMessage(Draglist&, &LVM_SETINSERTMARK, 0,structInsertMark#)
Set("WinProc", 0)
'Item markieren
SendMessage(DragList&,~Lb_SETCURSEL,LastItem&,0)
~SetCursor(MoveCursor&)
If Lastitem& = -1:Return 1:Endif
ElseIf Info#.uNotification& = &DL_DROPPED'Drag&Drop ist beendet
LastItem& = LVHTI#.Item&
If Lastitem& <> -1
'das erste gemerkte Item löschen
DeleteString(DragList&,FirstItem&)
'und an der Position des letzten gemerkten Items einfügen
InsertString(DragList&,LastItem&,MoveString$)
Set("WinProc", 0)
SelectString(Draglist&,-1,Movestring$)
EndIf
EndIf
Dispose structInsertMark#
Dispose Info#
EndIf
EndProc
Alles anzeigen