4.5 Pages

Each (non-silent) NSIS installer has a set of pages. Each page can be a NSIS built-in page or a custom page created by a user's function (with nsDialogs or InstallOptions for example).

The script controls the page order, appearance, and behavior. You can skip pages, paint them white, force the user to stay in a certain page until a certain condition is met, show a readme page, show custom designed pages for input and more. In this section you will learn how to do all of the above.

There are two basic commands regarding pages, Page and UninstPage. The first adds a page to the installer, the second adds a page to the uninstaller. On top of those two there is the PageEx command which allows you to add a page to either one and with greater amount of options. PageEx allows you to set options to the specific page you are adding instead of using the default that's set outside of PageEx.

4.5.1 Ordering

The page order is set simply by the order Page, UninstPage and PageEx appear in the script. For example:

  1. Page license
  2. Page components
  3. Page directory
  4. Page instfiles
  5. UninstPage uninstConfirm
  6. UninstPage instfiles

This code will tell NSIS to first show the license page, then the components selection page, then the directory selection page and finally the install log where sections are executed. The uninstaller will first show the uninstall confirmation page and then the uninstallation log.

You can specify the same page type more than once.

For backwards compatibility with old NSIS scripts, the following installer pages will be added if no installer page commands are used: license (if LicenseText and LicenseData were specified), components (if ComponentText was specified and there is more than one visible section), directory (if DirText was specified) and instfiles. When there are no uninstaller page commands the following uninstaller pages will be added: uninstall confirmation page (if UninstallText was specified) and instfiles. This method is deprecated, converting scripts to use page commands is highly recommended because you can use the new standard language strings.

4.5.2 Page Options

Each page has its unique set of data that defines how it will look and act. This section describes what data each type of page uses and how you can set it. Callback functions are described below and are not dealt with in this section.

The list below lists the commands that affect a certain page type. Unless otherwise mentioned, these commands can be used both inside and outside of a PageEx block. If used inside a PageEx block they will only affect the current page being set by PageEx, otherwise they will set the default for all other pages.

License page

Components selection page

Directory selection page

Un/Installation log page

Uninstall confirmation page

Use Caption to set the page caption.

4.5.3 Callbacks

Each built-in page has three callback functions: the pre-function, the show function and the leave-function. The pre-function is called right before the page is created, the show-function is called right after it has been created but before it is shown and the leave-function is called right after the user has pressed the next button (before actually leaving the page).

  • 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 etc.
  • The leave-function allows you to force the user to stay on the current page using Abort.

A custom page only has two callback functions, one that creates it which is mandatory, and one leave-function that acts just like the leave-function for built-in pages.

Examples:

  1. Page license skipLicense "" stayInLicense
  2. Page custom customPage "" ": custom page"
  3. Page instfiles
  4.  
  5. Function skipLicense
  6. MessageBox MB_YESNO "Do you want to skip the license page?" IDNO no
  7. Abort
  8. no:
  9. FunctionEnd
  10.  
  11. Function stayInLicense
  12. MessageBox MB_YESNO "Do you want to stay in the license page?" IDNO no
  13. Abort
  14. no:
  15. FunctionEnd
  16.  
  17. Function customPage
  18. GetTempFileName $R0
  19. File /oname=$R0 customPage.ini
  20. InstallOptions::dialog $R0
  21. Pop $R1
  22. StrCmp $R1 "cancel" done
  23. StrCmp $R1 "back" done
  24. StrCmp $R1 "success" done
  25. error: MessageBox MB_OK|MB_ICONSTOP "InstallOptions error:$\r$\n$R1"
  26. done:
  27. FunctionEnd

4.5.4 Page

  1. custom [creator_function] [leave_function] [caption] [/ENABLECANCEL]
  2. OR
  3. internal_page_type [pre_function] [show_function] [leave_function] [/ENABLECANCEL]

Adds an installer page. See the above sections for more information about built-in versus custom pages and about callback functions.

internal_page_type can be:

  • license - license page
  • components - components selection page
  • directory - installation directory selection page
  • instfiles - installation page where the sections are executed
  • uninstConfirm - uninstall confirmation page

The last page of the installer has its cancel button disabled to prevent confusion. To enable it anyway, use /ENABLECANCEL.

4.5.5 UninstPage

  1. custom [creator_function] [leave_function] [caption] [/ENABLECANCEL]
  2. OR
  3. internal_page_type [pre_function] [show_function] [leave_function] [/ENABLECANCEL]

Adds an uninstaller page. See the above sections for more information about built-in versus custom pages and about callback functions.

See Page for possible values of internal_page_type.

4.5.6 PageEx

  1. [un.](custom|uninstConfirm|license|components|directory|instfiles)

Adds an installer page or an uninstaller page if the un. prefix was used. Every PageEx must have a matching PageExEnd. In a PageEx block you can set options that are specific to this page and will not be used for other pages. Options that are not set will revert to what was set outside the PageEx block or the default if nothing was set. To set the sub-caption for a page use Caption or SubCaption to set the default. To set the callback functions for a page set with PageEx use PageCallbacks. See the above sections for more information about built-in versus custom pages.

Example usage:

  1. PageEx license
  2. LicenseText "Readme"
  3. LicenseData readme.rtf
  4. PageExEnd
  5.  
  6. PageEx license
  7. LicenseData license.txt
  8. LicenseForceSelection checkbox
  9. PageExEnd

4.5.7 PageExEnd

Ends a PageEx block.

4.5.8 PageCallbacks

  1. ([creator_function] [leave_function]) | ([pre_function] [show_function] [leave_function])

Sets the callback functions for a page defined using PageEx. Can only be used inside a PageEx block. See the above sections for more information about callback functions.

  1. PageEx license
  2. PageCallbacks licensePre licenseShow licenseLeave
  3. PageExEnd