views:

1059

answers:

2

My 1st page contains 2 radio buttons: 1 for install and other for upgrade. Depending upon user selection I have to show custom pages for installation or upgradation. How can I do this?

A: 

I have not tested it directly (I will soon, since my onw NSIS script will need that feature), but maybe the function RelGotoPage can do what you need.

This function makes NSIS to go to a specified page relatively from the current page.
Use it only on:

  • normal functions,
  • the ".onUserAbort" callback function (w/o MUI) or
  • the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI)

This function also allows InstallOptions and InstallOptionsEx to use its features so you can choose which controls will take the place of the default NSIS buttons.


Note: this thread suggests a different approach:

You should try and refrain from using RelGotoPage because when the user clicks the back button they will still be shown the page.
Instead what you should do is call Abort in page's pre functions and custom page's show functions if a certain condition is set to skip them.

So by setting adequate variable depending on your buttons, you can skip the pages you do not want to show, and stop at the relevant page.

See the Callback section of NSIS manual:

Each built-in page has three callback functions: the pre-function, the show-creation function and the leave-function.

  • The pre-function is called right before the page is created,
  • the show-function is called right after it is created and before it is shown and
  • the leave-function is called right after the user has pressed the next button and before the page is left.

And:

  • The pre-function allows you to skip the page using Abort.
  • The show-function allows you to tweak the page's user interface with CreateFont, SetCtlColors, SendMessage and others.
  • The leave-function allows you to force the user to stay on the current page using Abort.
VonC
+1  A: 

If you call abort in the create function callback for your custom page, the page will be skipped:

Function MyPage
${If} $somevar == "something"
Abort
${EndIf}
;Show page with nsDialogs or InstallOptions here...
FunctionEnd

page custom MyPage
Anders