03-23-2007, 03:52 PM
Can start from this.
Function FtpDirDlg
Function FD_Thread
Function FD_Folder
Function FtpDirDlg
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("FtpDirDlg" &FtpDirDlg)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 202 "Dialog"
;1 Button 0x54030001 0x4 120 186 48 14 "OK"
;2 Button 0x54030000 0x4 172 186 48 14 "Cancel"
;3 SysTreeView32 0x54000000 0x200 0 0 224 182 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020006 "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,mac "FD_Thread" "" id(3 hDlg)
,case WM_DESTROY
,shutdown -6 0 "FD_Thread"
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1Function FD_Thread
;\FtpDirDlg
function htv
type FTPDIRDATA Ftp'ftp htv ifoldericon
FTPDIRDATA f
f.ftp.Connect("ftp.arm.linux.org.uk" "anonymous" "anonymous")
f.htv=htv
;use system image list; get folder icon index
SHFILEINFO fi
int il=SHGetFileInfo(0 FILE_ATTRIBUTE_DIRECTORY &fi sizeof(fi) SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_SMALLICON)
f.ifoldericon=fi.iIcon
SendMessage(htv TVM_SETIMAGELIST 0 il)
FD_Folder f 0 "pub"Function FD_Folder
;/FtpDirDlg
function FTPDIRDATA&f hparent [$ftpdir]
if(len(ftpdir) and !f.ftp.DirSet(ftpdir)) ret
ARRAY(str) a
int i j
lpstr se
WIN32_FIND_DATA fd
lpstr s=f.ftp.Dir("*" 2 &fd)
rep
,if(s=0) break
,
,if !strcmp(s ".")
,else if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) TvAdd f.htv hparent s 0 f.ifoldericon
,else a[a.redim(-1)]=s
,
,s=f.ftp.Dir("" 2 &fd)
for i 0 a.len
,;out s
,s=a[i]
,
,;get icon index from file extension
,j=findcr(s '.'); if(j>=0) se=s+j; else se=0
,SHFILEINFO fi
,SHGetFileInfo(se 0 &fi sizeof(fi) SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_SMALLICON)
,
,TvAdd f.htv hparent s 0 fi.iIcon