DO
FUNCDEF("DRAGLISTINFO", "32u, 32u, 32, 32")
FUNCDEF("MakeDragList",", void", "comctl32")
FUNCDEF("RegisterWindowMessage","32u, str","user32")
FUNCDEF("LBItemFromPt","32, void, 32, 32, 32u", "comctl32")
FUNCDEF("DrawInsert",", void, void, 32u", "comctl32")
FUNCDEF("LoadStdCursor", "void, void, 32u", "user32", "LoadCursor")
FUNCDEF("SetCursor", "void, void", "user32")
CATCH FAILURE
CONDITION('M')
RETURN
END
crosshaircursor = loadstdcursor(, 32513)
nodropcursor = loadstdcursor(, 32648)
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_initdialog:
handle = guiinfo("HANDLE", "MyList")
makedraglist(handle)
dragmessage = registerwindowmessage("commctrl_DragListMsg")
RETURN ""
wm_extra:
IF ARG(3) = dragmessage THEN DO
CONVERTDATA(ARG(2), "DRAGLISTINFO", "struct DRAGLISTINFO")
SELECT draglistinfo.1
WHEN 1157 THEN DO
oldposition = lbitemfrompt(draglistinfo.2, draglistinfo.3, draglistinfo.4)
drawinsert(guiwindow, ARG(1), 1)
dragdrop = 0
RETURN 1
END
WHEN 1158 THEN DO
newposition = lbitemfrompt(draglistinfo.2, draglistinfo.3, draglistinfo.4)
IF newposition \= -1 THEN DO
setcursor(crosshaircursor)
dragdrop = 1
END
ELSE DO
setcursor(nodropcursor)
dragdrop = 0
END
END
WHEN 1159 THEN DO
IF dragdrop == 1 THEN DO
newposition = lbitemfrompt(draglistinfo.2, draglistinfo.3, draglistinfo.4)
IF newposition \= -1 THEN DO
guisendmsg("MyList", "GETLBTEXT", oldposition + 1, "text")
IF newposition > oldposition THEN newposition = newposition - 1
guisendmsg("MyList", "DELETESTRING", oldposition + 1)
guisendmsg("MyList", "INSERTSTRING", newposition + 1, text)
END
END
END
END
RETURN 0
END
RETURN "" |