Archive: Custom dropdown menu to show contents of a directory


Custom dropdown menu to show contents of a directory
First, I am using nsDialogs to select a folder.

Next, I need to make a dropdown menu which would load the list of all the directories from the folder above and let the user select one of them.

Any suggestions?


Use FindFirst, FindNext and FindClose to get the file entries in that folder, use IfFileExists "<root><found file entry>\*.*" for each found file entry to check if it's a folder, add to dropdown list items as you go.

If you want the results to be sorted, I'd recommend using NSISList or NSISArray as they have built-in sorting functions.

Here's an example of finding the dirs in the first place..


FindFirst $0 $1 "c:\*.*"
_loop:
StrCmp $1 "" _done
IfFileExists "c:\$1\*.*" 0 _next
MessageBox MB_OK "[$1]"
_next:
FindNext $0 $1
goto _loop
_done:
FindClose $0

Great help, thanks. I'll see where I can get with that.


It works very well. I used the following code to populate the nsDiaglogs DropList -

${If} $1 != ".."
${AndIf} $1 != "."
SendMessage $DropList ${CB_ADDSTRING} 0 "STR:$1"
EnableWindow $DropList 1
SendMessage $DropList ${CB_SELECTSTRING} 0 "STR:$1"
${EndIf}


awesome - glad it worked.. and yes, nsDialogs makes this sort of thing much easier (although it has a steeper learning curve than e.g. installoptions)