Archive: nsDialogs and Browse button for Dir/FileRequest


nsDialogs and Browse button for Dir/FileRequest
I've implemented a custom page using MUI2.nsh & nsDialogs but the documentation doesn't mention how to get a Browse button to work in conjunction with the FileRequest or DirRequest controls - it has a separate NSD_CreateBrowseButton but I don't know how to return the selected file/dir to the appropriate controls.

Also, will the FileRequest and DirRequest controls validate the path if a user just types one in?


i had problems using the browse-button (in an earlier version), but i used a normal button instead. here's my code for that.

${NSD_CreateButton} 330 75 25 20 "..."
Pop $Browse
GetFunctionAddress $0 OnClick_Browse
nsDialogs::OnClick /NOUNLOAD $Browse $0

...

Function OnClick_Browse
nsDialogs::SelectFolderDialog /NOUNLOAD "Please select a target directory" "$Directory"
Pop $0
${If} $0 == error
Abort
${EndIf}
SendMessage $Directory ${WM_SETTEXT} 0 "STR:$0"
FunctionEnd


you need to do validation etc in an extra function (unless that's the difference with browse-button!). either way, you will get the picture.

Thanks Yathosho! Can you explain this line:

ShowWindow $BU1_Browse ${SW_HIDE}

Also, what does the $Directory1 variable do?


oh, please forget about the ShowWindow line, i accidently pasted it from my script. the $Directory variable is the default directory you might want to show in the dialog.


One last question: how do I return the selected folder\file to a text control (or DirRequest control)?