09stephenb Posted January 6, 2015 Share Posted January 6, 2015 This is my code so far. expandcollapse popup#include <GUIConstantsEx.au3> #include <File.au3> #include <GUIConstants.au3> #include <array.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <APIRegConstants.au3> #include <WinAPIReg.au3> GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") HotKeySet("{esc}","exitx") HotKeySet("{f5}","regen") $valpath=@ScriptDir&"\Vault" $rootpath=$valpath $largeicons=1 $menu=GUICreate("Vault", 700, 400, -1, -1, -1, $WS_EX_ACCEPTFILES) $browsevault=GUICtrlCreateListView(" | File / Folder name | Size ", 0, 0, 700, 400) _GUICtrlListView_SetExtendedListViewStyle($browsevault, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) GUISetState() regen() $DoubleClicked = False While 1 Sleep(100) If $DoubleClicked Then DoubleClickFunc() $DoubleClicked = False EndIf WEnd Func DoubleClickFunc() $Select = ControlListView($menu, "", $browsevault, "GetSelected") $item=ControlListView($menu, "", $browsevault, "GetText", $Select, 1) If DirGetSize($valpath&"\"&$item) <> "-1" Then $valpath=$valpath&"\"&$item regen() EndIf EndFunc Func regen() _GUICtrlListView_DeleteAllItems($browsevault) $hImage = _GUIImageList_Create(24, 24 ,5 ,3) _GUIImageList_AddIcon($hImage,@WindowsDir&"\System32\Shell32.dll",4,$largeicons) $icon_array=_FileListToArrayRec($valpath,"*",1) $minus=0 $iIndex = _ArraySearch($icon_array, "Desktop.ini", 1, 0, 0, 1) If Not @error Then _ArrayDelete($icon_array, $iIndex) $minus=1 EndIf $iconindex=1 For $i = 1 To $icon_array[0]-$minus Dim $a, $b, $c, $ext $pth=_PathSplit($valpath&"\"&$icon_array[$i],$a,$b,$c,$ext) If @error Then $pathtoico=$fileicopth $icoindex=0 Else $ext=$pth[4] If $ext=".ico" Then $pathtoico=$icon_array[$i] $icoindex=0 Else $fileicopth=$icon_array[$i] $str=_WinAPI_AssocQueryString($ext, $ASSOCSTR_DEFAULTICON) $end=0 $loop=StringLen($str) If StringRight($str,4)=".ico" Then $pathtoico=$str $icoindex=0 Else While $end<>1 If StringMid($str,$loop,1)="," Then $end=1 EndIf $loop=$loop-1 Wend $strtrm=$loop-StringLen($str)+1 $strtrm=($strtrm-$strtrm)-$strtrm $pathtoico=StringTrimRight($str,$strtrm+1) $icoindex=StringRight($str,$strtrm) EndIf EndIf EndIf _GUIImageList_AddIcon($hImage,$pathtoico,$icoindex,$largeicons) $iconindex=$iconindex+1 Next _GUICtrlListView_SetImageList($browsevault, $hImage, 1) $line=1 $folder_array=_FileListToArray($valpath,"*",2) If Not(@error) Then For $i = 1 To $folder_array[0] _GUICtrlListView_AddItem($browsevault,"", 0) _GUICtrlListView_AddSubItem($browsevault, $line-1, $folder_array[$i], 1, 1) _GUICtrlListView_AddSubItem($browsevault, $line-1, Round(DirGetSize($valpath&"\"&$folder_array[$i])/1048576,2)&" MB", 2, 1) $line=$line+1 Next EndIf $dirend=$line $line=0 $file_array=_FileListToArrayRec($valpath,"*",1) If Not(@error) Then $iIndex = _ArraySearch($file_array, "Desktop.ini", 1, 0, 0, 1) If Not @error Then _ArrayDelete($file_array, $iIndex) EndIf $icondex=1 For $i = 1 To $file_array[0]-1 _GUICtrlListView_AddItem($browsevault,"", $icondex) _GUICtrlListView_AddSubItem($browsevault, $line+$dirend-1, $file_array[$i], 1, 1) _GUICtrlListView_AddSubItem($browsevault, $line+$dirend-1, Round(FileGetSize($valpath&"\"&$file_array[$i])/1048576,2)&" MB", 2, 1) $line=$line+1 $icondex=$icondex+1 Next EndIf EndFunc Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) $code = DllStructGetData($tagNMHDR, 3) If $wParam = $browsevault And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSG EndFunc Func exitx() exit EndFunc It works with the root path but when i open the folders the icons stop working. Does anyone know what i am doing wrong. Example of the problem: Link Link to comment Share on other sites More sharing options...
kylomas Posted January 7, 2015 Share Posted January 7, 2015 09stephenb, You will get better response if you post runnable code... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now