' Allow dragging and dropping of files $TYPECHECK ON CONST WM_DROPFILES = &H233 TYPE TPOINT X AS LONG Y AS LONG END TYPE DIM Point AS TPOINT DECLARE SUB DragAcceptFiles LIB "SHELL32" ALIAS "DragAcceptFiles" (hWnd AS LONG, Accept AS LONG) DECLARE SUB DragFinish LIB "SHELL32" ALIAS "DragFinish" (hDrop AS LONG) DECLARE FUNCTION DragQueryFile LIB "SHELL32" ALIAS "DragQueryFileA" _ (hDrop AS LONG, iFile AS LONG, lpszFile AS LONG, cch AS LONG) AS LONG DECLARE FUNCTION DragQueryPoint LIB "SHELL32" ALIAS "DragQueryPoint" _ (hDrop AS LONG, lppt AS TPOINT) AS LONG DECLARE SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&) DIM Form AS QForm DIM Listbox as QLISTBOX Listbox.parent = form DIM S AS STRING DIM I AS INTEGER, Count AS INTEGER, Length AS INTEGER Form.Caption = "Drag and drop files" Form.Center DragAcceptFiles(Form.Handle, 1) Form.WndProc = FormWndProc Form.ShowModal SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&) IF uMsg& = WM_DROPFILES THEN DragQueryPoint(wParam&, Point) IF Point.X >= ListBox.Left AND Point.Y >= ListBox.Top AND _ Point.X < ListBox.Width AND Point.Y < ListBox.Height THEN Count = DragQueryFile(wParam&, &HFFFFFFFF, VARPTR(S), 0) FOR I = 0 TO Count-1 Length = DragQueryFile(wParam&, I, 0, 0) S = SPACE$(Length+1) DragQueryFile(wParam&, I, VARPTR(S), Length+1) ListBox.AddItems(S) NEXT ELSE ShowMessage("Try dragging the files to the listbox") END IF DragFinish(wParam&) END IF END SUB