Archive: MUI_PAGE_DIRECTORY not shown in some cases


MUI_PAGE_DIRECTORY not shown in some cases
Hi all,

When my setup is run, if the product is already installed, I show a custom page with the following options: uninstall before installing, uninstall only, overwrite files only. In case "overwrite files only" is chosen I would like _not_ to show the installation-directory-page MUI_PAGE_DIRECTORY, as I don't want the user to choose another directory, b/c I want the INSTDIR to be the one from previous installation.

So, how can I not show the MUI_PAGE_DIRECTORY page in case a specific option was chosen on a custom page.

Thx,
Viv


From NSIS manual, about Pages...
"The pre-function allows you to skip the page using Abort."


Thx galil,

I'm using the Modern UI so the Pages section from help doesn't really apply. But following that info, I was able to find the info I need in the NSIS\Docs\Modern UI\Readme.html in the "Page Custom Functions". Seems that I need to define the
MUI_PAGE_CUSTOMFUNCTION_PRE function
just before the
!insertmacro MUI_PAGE_DIRECTORY
and then in function to just Abort in case needed.

Thx,
Viv


Originally posted by coco_vc
I'm using the Modern UI so the Pages section from help doesn't really apply.
How does it not apply if you can skip a page with Abort command in callback "pre" function regardless of which UI you are using?
Everything does apply. Concept and mechanics are the same. It's just a matter of different syntax in some cases between Standard and Modern UI (which uses defines and macros more). In fact you could even define pages in modern script the "old" way:
Page directory prefunc
instead of the "modern" and more cumbersome way with define and insertmacro, and still get the same working modern UI.

Of course it isn't recommended.
Just create the callbacks like so:

!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

All of this is in the Modern UI documentation.

-Stu


There is a perfect "builtin"-example for such a feature which coco_vc tries to realize.

The installer file for NSIS itself.
$NSISDIR\examples\makensis.nsi

!ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
Page custom PageReinstall PageLeaveReinstall
!endif

The PRE function "PageReinstall" checks the registry which NSIS version is already installed and shows a custom dialog depending on the result. It's very modern usage of MUI macros.

By the way, NSIS installer offers the selection of another target directory even if it is already installed. Thats exactly what coco_vc tries to avoid.

Is there a reason why this is still enabled???


Is there a reason why this is still enabled???
Why shouldn't this be enabled? The user shouldn't be forced to install the application anywhere. What if he wants to have two versions side-by-side?

Originally posted by Afrow UK
Put of course it isn't recommended.
Just create the callbacks like so:

!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

All of this is in the Modern UI documentation.

-Stu
I spend several hours trying to figure out why my custom function named "SkipDirectory" was zero'ed out by the compiler as an unreferenced custom function. Of course when I renamed the function to DirectoryPre it worked fine. This would seem to be a bug when you have to guess at what the custome function should be called.

You don't have to guess, you set it with MUI_PAGE_CUSTOMFUNCTION_PRE.


Originally posted by kichik
You don't have to guess, you set it with MUI_PAGE_CUSTOMFUNCTION_PRE.
I did that with many different names that did not work including the one in my previous post. The only one that worked for me was DirectoryPre.

No, you still have the wrong end of the stick!

!define MUI_PAGE_CUSTOMFUNCTION_PRE MyFunc
...

Function MyFunc
...

If the function name set with MUI_PAGE_CUSTOMFUNCTION_PRE does not exist then your script will not compile.

Stu