Introduction

NSIS 2 makes it is possible to create installers with a custom user interface.

I made this interface with a modern wizard style, like the wizards of recent Windows versions. This new interface also features new graphics and a description area on the component-selection page.

To use this new interface for for installer, you need to add some code to your NSIS script. Read this document for more info!

Requirements

NSIS 2 beta 0 (or later)

Screenshots

How to use

The Modern UI has a macro system, so most of the code has already been written for you!

The easiest way to use the Modern UI is to customize one of the example scripts, but you can also modify an existing script.

Note: If you want to add a double quote (") to a Modern UI string, you should always escape it ($\"), because the Modern UI macro's use " to separate parameters.

How to use the Modern UI in an existing script:

1. Include the header file

!include "${NSISDIR}\Contrib\Modern UI\System.nsh"

2. Define the name and version of your software

!define MUI_PRODUCT "Test Software" ;Define your own software name here
!define MUI_VERSION "1.0" ;Define your own software version here

3. Define which elements you are using

The Modern UI should know which things it should insert. Use the following defines:

!define MUI_WELCOMEPAGE ;Welcome page
!define MUI_LICENSEPAGE ;License page
!define MUI_COMPONENTSPAGE ;Component-selection page
!define MUI_DIRECTORYPAGE ;Directory-selection page
!define MUI_STARTMENUPAGE ;Start Menu Folder selection page
!define MUI_FINISHPAGE ;Finish page with options to run the program or reboot
  !define MUI_FINISHPAGE_RUN "$INSTDIR\File.exe" ;Option to run a file
  !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Readme.txt" ;Option to show a Readme
  !define MUI_FINISHPAGE_NOREBOOTSUPPORT ;Disables support for a reboot option.
                                         ;Use this if you are not using /REBOOTOK
                                         ;or SetRebootFlag.

!define MUI_ABORTWARNING ;Abort warning messagebox
!define MUI_CUSTOMPAGECOMMANDS ;Use customized pages
!define MUI_CUSTOMGUIINIT ;Use customized .onGUIInit function

!define MUI_UNINSTALLER ;Uninstaller
!define MUI_UNCUSTOMPAGECOMMANDS ;Use customized uninstaller pages
!define MUI_UNCUSTOMGUIINIT ;Use customized un.onGUIInit function

4. Insert language files

Insert the Modern UI language files for the languages you are using:

!insertmacro MUI_LANGUAGE "English"

The Modern UI language files load the NLF language files, so you should not use LoadLanguageFile.

You don't need to edit the language files if you want to customize some strings. Use defines before you insert the language file:

!define MUI_INNERTEXT_LICENSE_TOP "Text on the top of the license dialog"
!insertmacro MUI_LANGUAGE "English"

Have a look at the language files for a complete list of all the names.

NOTE: Not all language files contain strings for the new Start Menu Folder selection, Welcome and Finish pages yet. If you are using one of these pages and the language file does not contain these strings, you should always define them.
Please help to translate the new strings and post them at the NSIS Forum.

5. Define interface settings (optional)

You can change the settings of the interface by usings defines:

!define MUI_UI "${NSISDIR}\Contrib\UIs\modern2.exe"

If you don't define a setting, the default will be used.

The following settings are available: (default values)

MUI_UI (${NSISDIR}\Contrib\UIs\modern.exe)
The interface file with the dialog resources

MUI_ICON (${NSISDIR}\Contrib\Icons\modern-install.ico)
The icon of the instaleller

MUI_UNICON (${NSISDIR}\Contrib\Icons\modern-uninstall.ico)
The icon of the uninstaleller

MUI_CHECKBITMAP (${NSISDIR}\Contrib\Icons\modern.bmp)
The bitmap with images for the checks of the component select treeview

MUI_BRANDINGTEXT (Nullsoft Install System ?.??)
The text at the bottom left corner of the window

MUI_FONT, MUI_FONTSIZE (MS Shell Dlg, 8)
The font for the normal texts.

MUI_FONT_HEADER, MUI_FONTSIZE_HEADER, MUI_FONTSTYLE_HEADER (MS Sans Serif, 8, 700)
The font for the title in the header. Fontstyle: [weight] [/ITALIC] [/UNDERLINE] [/STRIKE]

MUI_FONT_TITLE, MUI_FONTSIZE_TITLE, MUI_FONTSTYLE_TITLE (Verdana, 12, 700)
The font for the title on the Welcome and Finish pages. Fontstyle: [weight] [/ITALIC] [/UNDERLINE] [/STRIKE]

MUI_INSTALLCOLORS (/windows)
The hexadecimal colors of the details screen ("foreground" "background")

MUI_PROGRESSBAR (smooth)
The style of the progress bar ("colored" to use the MUI_INSTALLCOLORS or "" for a old-school windows look)

MUI_SPECIALINI (${NSISDIR}\Contrib\ioSpecial.ini)
Install Options INI File for the Welcome and Finish pages

MUI_SPECIALBITMAP (${NSISDIR}\Contrib\Icons\modern-wizard.bmp)
Bitmap for the Welcome and Finish pages

6. Insert the MUI_SYSTEM macro

!insertmacro MUI_SYSTEM

7. Insert the MUI_SECTIONS_FINISHHEADER macro

If you are not using a Finish page, you should insert the MUI_SECTIONS_FINISHHEADER after all the sections to display the finish-header.

!insertmacro MUI_SECTIONS_FINISHHEADER

In the uninstaller, insert MUI_UNFINISHHEADER at the end of the Unintaller section.

!insertmacro MUI_UNFINISHHEADER

8. Set the descriptions for the sections

Insert the description macro's to set the descriptions for the sections. These descriptions will be displayed when the user hovers the mouse over a component in the component-selection page:

LangString DESC_SectionName1 ${LANG_ENGLISH} "Description of section 1."
LangString DESC_SectionName2 ${LANG_ENGLISH} "Description of section 2."

!insertmacro MUI_FUNCTIONS_DESCRIPTION_START
  !insertmacro MUI_DESCRIPTION_TEXT ${SectionName1} $(DESC_SectionName1)
  !insertmacro MUI_DESCRIPTION_TEXT ${SectionName2} $(DESC_SectionName2)
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END

Always set a name for a section:

Section "Section Name 1" SectionName1
 ...
SectionEnd

Section "Section Name 2" SectionName2
 ...
SectionEnd

Custom pages

Have a look at the Install Options documentation for info about creating Install Options INI Files.

Custom page commands

If you want add custom pages to your installer, you should insert your own page commands to set the order of the pages and the names of the page functions.

LangString TEXT_IO_WINDOWTITLE ": Install Options Page Title"

!insertmacro MUI_PAGECOMMAND_WELCOME
!insertmacro MUI_PAGECOMMAND_LICENSE
!insertmacro MUI_PAGECOMMAND_COMPONENTS
!insertmacro MUI_PAGECOMMAND_DIRECTORY
Page custom FunctionName $(TEXT_IO_WINDOWTITLE) ;A custom page
!insertmacro MUI_PAGECOMMAND_INSTFILES
!insertmacro MUI_PAGECOMMAND_FINISH

This is also possible in the uninstaller:

LangString UNTEXT_IO_WINDOWTITLE ": Install Options Page Title"

!insertmacro MUI_UNPAGECOMMAND_CONFIRM
UninstPage custom FunctionName $(TEXT_IO_WINDOWTITLE) ;A custom page
!insertmacro MUI_UNPAGECOMMAND_INSTFILES

Don't forget to define MUI_CUSTOMPAGECOMMANDS or MUI_UNCUSTOMPAGECOMMANDS before inserting the MUI_SYSTEM macro.

Call Install Options

You can call Install Options in FunctionName:

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Install Options Page Title"
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "A subtitle"

Function FunctionName
  !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
  !insertmacro MUI_INSTALLOPTIONS_SHOW "ioFile.ini"
FunctionEnd

Examples

Basic: Basic.nsi
Multilanguage: MultiLanguage.nsi
Custom pages: InstallOptions.nsi
Start Menu Folder selection: StartMenu.nsi
Welcome/Finish page: WelcomeFinish.nsi

The interface

Modern.exe and modern2.exe

There are two different versions of the interface available. Modern.exe contains the dialogs of the standard interface. If you have an installer with a lot of subsections or long section names, use modern2.exe, which has a different component-selection page.

Customize the dialogs

To change elements on the dialogs, modify modern.exe or modern2.exe in the Contrib\UIs directory using a resource editor such as Resource Hacker.

The 'Loading Setup' text on the splash screen which is being displayed when the installer is starting (Verifying installer, Unpacking data) cannot be changed by the script, because the installer is not started yet when this dialog is being displayed. If you want to change this text, modify dialog 111 of modern(2).exe.
The 'Verifying installer' and 'Unpacking data' texts are defined in the language header file of the NSIS exehead (Source\exehead\lang.h). To change them, you need to edit this file and recompile NSIS.

To modify the Welcome and Finish dialog, edit the Install Options INI File ioWizard.ini in the 'Contrib\Modern UI' directory.

Customize the GUIInit function

If you want to insert your own code in the .onGUIInit function, define MUI_CUSTOMGUIINIT (MUI_UNCUSTOMGUIINIT for the uninstaller) before inserting MUI_SYSTEM and insert the MUI_GUIINIT (MUI_UNGUIINIT for the uninstaller) macro in your .onGUIInit or un.onGUInit function.

!define MUI_CUSTOMGUIINIT

Function .onGUIInit
  !insertmacro MUI_GUIINIT
  ...your own code...
FunctionEnd

Version history

  • 1.6 - November 18, 2002
    • Welcome / Finish pages
    • Automatic ask for reboot on finish page
    • Create no shortcut option on Start Menu Folder selection page
    • Customizing GUIInit functions easier
    • Minor font / UI changes

  • 1.5 - November 11, 2002
    • New language file format
    • Language strings can be changed in the script without editing language files
    • Start Menu Folder selection page
    • 'Click Next to continue' and 'Click Install to start the installation' texts automatically change to the page order
    • Install Options macro's updated. MUI_INSTALLOPTIONS_DISPLAY is the standard macro now. Use MUI_INSTALLOPTIONS_INITDIALOG and MUI_INSTALLOPTIONS_SHOW if you want to customize dialog controls.
    • No more writing window titles & abort warnings to Install Options INI Files
    • Compatible with updated paging system
    • Renamed macro's and defines
    • Some small fixes

Complete version history

Credits

Made by Joost Verburg.
Icons designed by Nikos Adamamas, aka adni18.
Thanks to Amir Szekely, aka KiCHiK, for his work on NSIS to make this possible.

Help

Please post questions at the NSIS Forum.

License

Copyright © 2002 Joost Verburg

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; 
   you must not claim that you wrote the original software.
   If you use this software in a product, an acknowledgment in the
   product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
   and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution.