Archive: Open file window


Open file window
Hello everyone,
I am once again showing my noobness to the forum by asking a noob question. I am looking to use a open file window but I have yet to find it in NSIS. I assume that it is really a windows call but I have not found it as of yet. Anyone have any good pointers?

Thanks in advance.


If you plan to use it in a function take a look here,

http://nsis.sourceforge.net/FileRequ...on_or_function

Otherwise the usual way is to build a custom page either with InstallOptions or the newly added nsDialogs.
Both are included into nsis distribution.


That worked great. Thanks!!


That code works but isn't very clean.
I would recommend writing custom code:


StrCpy $3 `(&l4, i, i 0, i, i 0, i 0, i 0, t, i ${NSIS_MAX_STRLEN}, t, i ${NSIS_MAX_STRLEN}, t, t, i, &i2, &i2, t, i 0, i 0, i 0)`
System::Call '*(&t23 "HTML Document (*.html)", &t7 "*.html", &i1 0) i.r0'
System::Call '*$3 i (,$HWNDPARENT,,r0,,,,"${FileName}",,"",,"$DESKTOP","${Caption}",0xA01800,,,,,,) .r1'
System::Call 'comdlg32::GetSaveFileName(i r1) i .r2'
System::Call '*$1$3(,,,,,,,.R0)'
System::Free $1
System::Free $0

${FileName} is the initial file name, $DESKTOP is the initial directory and ${Caption} is of course the dialog caption. This bit specifies the filters:
System::Call '*(&t23 "HTML Document (*.html)", &t7 "*.html", &i1 0) i.r0'

23 is the length of the proceeding string +1. You can add more like so:
System::Call '*(&t23 "HTML Document (*.html)", &t7 "*.html", &t19 "Text Files (*.txt)", &t6 "*.txt", &i1 0) i.r0'
The &i1 0 marks the end of the list (double null).

Stu

Thanks for all your help Afrow!!
I'll give this a try now.


major props to you Afrow. one last thing is there a good way to add error trapping to that so that if they cancel it handles it gracefully?


Yep $R0 will be empty if Cancel was pressed or the file path selected otherwise. You can also check the return value of GetSaveFileName which is stored in $2. It will be 0 on failure.

Stu


Thanks Afrow! You are Uber!