Archive: NSD_CreateDirRequest does not work


NSD_CreateDirRequest does not work
Hello! I already searched for anything that could help me to solve this, but found no solution. From the nsDialogs example I could not create a DirRequest. Actually, it creates an edit box, but with no browse button.

What could be wrong? Here is the code:


!include LogicLib.nsh
!include nsDialogs.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
Var MyDir

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage

nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog

${If} $Dialog == error
Abort
${EndIf}

${NSD_CreateDirRequest} 0 0 100% 12u "Choose a directory"
Pop $MyDir

nsDialogs::Show

FunctionEnd

Section

DetailPrint "hello world"

SectionEnd

You have to separately create the button and add an OnClick callback function to it. In Include\nsDialogs.nsh find OnDirBrowseButton for an example usage.

If possible, make an example code out of it and I'll add it as a nsDialgs example.


Interesting. Before I post the question I was just making what you told me to do. :-)

I searched in nsDialogs.nsg (hoping to find any clues) and found a DirRequest function that seems to create properly what I wanted. What I can't understand is why there is a CreateDirRequest if it does not create one and what is the difference to a simple input text box.

Thanks for the reply.


I have created a simple function that creates a DirRequest and accept a suffix to be automatically appended to the end of the path choosed. This is handy to indicate to the user the final path of installation (my application has many componentes that are installed at different paths). The function has one little limitation: is does not work with width and X coordinate, but this can be easily changed if someone is interested.

Some parts of my code is based on nsDialogs.nsh, including writing to an ini file. Is there a way to make this file temporary, i.e., be automatically deleted at the end of the installation?

I am attaching the function so you can send me any ideias and use it (if it is good for you).

Thanks! :up:

Edit: I found a little bug, in the last push of MyCreateDirRequest, isn't $0 to be pushed, but $R0. By the way, what is the difference between $R* and $*?


just to drag this back up...

the difference between $N and $RN is just the R..
You have $0, $1, $2, $3, $4, $5, $6, $7, $8, $9 - 10 'temporary' variables that you can always assign stuff to. But some people were quickly hitting the 10 limit so $10, through $19 were added. These last 10 you can also access as $R0 through $R9.
So there's no functional difference.. they're just more temp variables.

as for DirRequest and FileRequest - yes, they're the same as a Text control. The BrowseButton is also the same as a regular Button control.

Not sure why they were added with these names, maybe different default styles were planned for them at some point, maybe early tests showed people thought controls were 'missing' if they didn't encounter these names (although subsequent confusion over the lack of a browse button if creating a dir/filerequest control may be even worse, imho)


Grrr, the documentation needs updating, I just wasted ages on this exact problem.

"nsDialogs doesn't use INI files, so it's way faster than InstallOptions."

Wrong, it's a total pain in the ass... Sorry....


having worked with nsDialogs for some time now - I can honestly say it is -much- more flexible and it runs faster... however, creating content with it is slower.

This is mostly due to a lack of an IDE taking advantage of nsDialogs, though.

I certainly much prefer it to having an external .ini file which specifies whether or not a control reacts to anything, and then having a single function that handles any such actions and having to check whether it's the one you care about or not, etc.

But, to each their own, and InstallOptionsEx served me quite well before I made the jump to nsDialogs (InstallOptionsEx adds tons of functionality not in the original InstallOptions/InstallOptions2) - so if you prefer the ini route, try that :)