Ivan Andreevich
10th December 2008 18:37 UTC
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?
Animaether
11th December 2008 07:47 UTC
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
Ivan Andreevich
11th December 2008 18:49 UTC
Great help, thanks. I'll see where I can get with that.
Ivan Andreevich
16th December 2008 21:55 UTC
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}
Animaether
16th December 2008 22:09 UTC
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)