Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drag Drop ListBox..
#7
di.files is populated only on drop. To decide what cursor to show, we need files on drag enter. Function QMDRAGDROPFILES.GetFiles extracts file paths from the data object.

Member function QMDRAGDROPINFO.GetFiles
Code:
Copy      Help
function# ARRAY(str)&a [flags] ;;flags: 1 free memory (called on drop)

;Gets paths of file(s) being dragged or dropped.
;Returns the number of files.
;Does not support non-file objects, such as control panel items.


a=0
int i
for(i 0 formats.len) if(formats[i].cfFormat=CF_HDROP) goto g1
ret
;g1
#opt nowarnings 1
STGMEDIUM sm ;;warning because of composites in union
dataObj.GetData(&formats[i] &sm); err ret
if(sm.tymed!=TYMED_HGLOBAL) ret
BSTR b.alloc(300)
for i 0 DragQueryFileW(sm.hGlobal -1 0 0)
,DragQueryFileW(sm.hGlobal i b 300)
,a[].ansi(b)

if(flags&1) DragFinish sm.hGlobal
ret a.len

Function dlg_tv_drop_files
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_tv_drop_files" &dlg_tv_drop_files 0 _hwndqm)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTreeView32 0x54030000 0x0 0 0 116 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030002 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,QmRegisterDropTarget(id(3 hDlg) hDlg 1)
,
,case WM_QM_DRAGDROP ;;we receive this message on drag enter (flag 1) and on drop (always)
,QMDRAGDROPINFO& di=+lParam
,di.effect=0
,ARRAY(str) a amp3
,if(di.GetFiles(a wParam=3) and GetMp3Files(a amp3))
,,di.effect=4 ;;shortcut
,,if(wParam=3) ;;on drop
,,,int i htv=id(3 hDlg)
,,,for i 0 amp3.len
,,,,TvAdd(htv 0 amp3[i])
,
,ret DT_Ret(hDlg 1)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Function GetMp3Files
Code:
Copy      Help
;/
function# ARRAY(str)&a ARRAY(str)&amp3

;Gets mp3 files from a.
;
;Returns the number of mp3 files.
;For folders, gets all mp3 files that are in the folders, including all subfolders.

;a - files of any type, including folders.
;amp3 - receives mp3 files that are in a.


amp3=0
str s; int i
for i 0 a.len
,s=a[i]
,if(dir(s 1)) ;;folder
,,s+"\*"
,,Dir d
,,foreach(d s FE_Dir 4)
,,,str sPath=d.FileName(1)
,,,if(sPath.endi(".mp3")) amp3[]=sPath
,else ;;file
,,if(s.endi(".mp3")) amp3[]=s
ret amp3.len


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)