File Request Return Value in nsdialogs
I'm using a custom dialog with nsdialogs to get the user to select a file. Im using a file request text box with a browse button for this. Im also using a variable to hold and remember the state of the text box with the user selects a file using the browse button. My problem occurs when the user cancels browsing for the file instead of selecting it. In this case it's supposed to return a blank value "". But instead it returns a random number sometimes. Here are the relevant parts of the script ...
Function InstallSelect
nsDialogs::Create /NOUNLOAD 1018
Pop $PathForInstallDialog
${If} $PathForInstallDialog == error
MessageBox MB_ICONSTOP|MB_OK "Error drawing dialog. Please try Setup again." /SD IDOK
Quit
${EndIf}
; Create Controls
${NSD_CreateGroupBox} 0 0 100% 100% ""
Pop $PathForInstallGroupBox
${NSD_CreateLabel} 10u 17u 280u 24u "Please select the install file, and click next to continue"
Pop $PathForInstallLabel
${NSD_CreateFileRequest} 10u 86u 260u 12u $PathForInstallFileRequestState
Pop $PathForInstallFileRequest
${NSD_CreateBrowseButton} 275u 86u 15u 12u "..."
Pop $PathForInstallFileBrowse
GetFunctionAddress $0 OnBrowseForFile
nsDialogs::OnClick /NOUNLOAD $PathForInstallFileBrowse $0
nsDialogs::Show ;Display the dialog
FunctionEnd
Function OnBrowseForFile
nsDialogs::SelectFileDialog /NOUNLOAD "open" "" "All files (*.*)|*.*"
Pop $0
StrCpy $PathForInstallFileRequestState $0
${NSD_SetText} $PathForInstallFileRequest $PathForInstallFileRequestState
FunctionEnd