IntroductionThe Modern UI provides a user interface for NSIS installers with a modern wizard style, similar to the wizards of recent Windows versions. It is based on the basic user interface that is provided by the NSIS compiler itself and extends it with more interface features and pages. All standard NSIS pages (such as the pages to select components and the installation folder) are supported as well as a number of additional pages. The welcome page allows you to provide an introduction to the installation process, while the finish page provides a way to let the user decide what steps should be performed after the setup wizard is closed (for example, whether the application should be started immediately). A finish page can also be used to ask for a system restart is necessary. Screenshots
Modern UI 2.0This new version makes it easier to customize pages, because the same method can be used to change standard NSIS pages as well as additional pages provided by the Modern UI. It is now also possible for other NSIS plug-ins to add new pages to the Modern UI. You can expect to see examples of this soon. The welcome and finish page are no longer implemented using InstallOptions. Instead, the new nsDialogs plug-in is used. nsDialogs allows you to create custom pages or customize existing pages directly from the script. To upgrade a Modern UI 1.8 script, you should:
Script headerThe settings for the Modern UI should be inserted in the header of the script file. It's important to follow the same order as the items below. For example, interface settings should be defined before you insert pages, because the pages depend on the interface configuration. It may be useful to look at the example scripts too see how this is done in actual script files. Parameters are given in this format: required (option1 | option2) [optional] 1. Header fileFirst of all, add this line to the top of script to include the Modern UI: !include MUI2.nsh 2. Interface configurationThen, you may want to use interface settings to change the look and feel of the installer. These settings apply to all pages. The interface settings provided by the NSIS compiler itself (such as LicenseText, Icon, CheckBitmap, InstallColors) should not be used in Modern UI scripts. The Modern UI provides equalivent or extended versions of these settings. Examples: !define MUI_COMPONENTSPAGE_SMALLDESC ;No value !define MUI_UI "myUI.exe" ;Value !define MUI_INSTFILESPAGE_COLORS "FFFFFF 000000" ;Two colors Interface settingsPage header
MUI_ICON icon_file
MUI_UNICON icon_file
MUI_HEADERIMAGE
MUI_HEADERIMAGE_BITMAP bmp_file
MUI_HEADERIMAGE_BITMAP_NOSTRETCH
MUI_HEADERIMAGE_BITMAP_RTL bmp_file
MUI_HEADERIMAGE_BITMAP_RTL_NOSTRETCH
MUI_HEADERIMAGE_UNBITMAP bmp_file
MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH
MUI_HEADERIMAGE_UNBITMAP_RTL bmp_file
MUI_HEADERIMAGE_UNBITMAP_RTL_NOSTRETCH
MUI_HEADERIMAGE_RIGHT
MUI_BGCOLOR (color: RRGGBBR hexadecimal)
MUI_HEADER_TRANSPARENT_TEXT Interface resources
MUI_UI ui_file
MUI_UI_HEADERIMAGE ui_file
MUI_UI_HEADERIMAGE_RIGHT ui_file
MUI_UI_COMPONENTSPAGE_SMALLDESC ui_file
MUI_UI_COMPONENTSPAGE_NODESC ui_file Installer welcome/finish page
MUI_WELCOMEFINISHPAGE_BITMAP bmp_file
MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH Uninstaller welcome/finish page
MUI_UNWELCOMEFINISHPAGE_BITMAP bmp_file
MUI_UNWELCOMEFINISHPAGE_BITMAP_NOSTRETCH License page
MUI_LICENSEPAGE_BGCOLOR (/windows | /grey |
(color: RRGGBB hexadecimal)) Components page
MUI_COMPONENTSPAGE_CHECKBITMAP bitmap_file
MUI_COMPONENTSPAGE_SMALLDESC
MUI_COMPONENTSPAGE_NODESC Directory page
MUI_DIRECTORYPAGE_BGCOLOR (color: RRGGBB hexadecimal) Start Menu folder page
MUI_STARTMENUPAGE_BGCOLOR (color: RRGGBB hexadecimal) Installation page
MUI_INSTFILESPAGE_COLORS (/windows | "(foreground
color: RRGGBB hexadecimal) (background color: RRGGBB hexadecimal)")
MUI_INSTFILESPAGE_PROGRESSBAR (""
| colored | smooth) Installer finish page
MUI_FINISHPAGE_NOAUTOCLOSE Uninstaller finish page
MUI_UNFINISHPAGE_NOAUTOCLOSE Abort warning
MUI_ABORTWARNING
MUI_ABORTWARNING_TEXT text
MUI_ABORTWARNING_CANCEL_DEFAULT Uninstaller abort warning
MUI_UNABORTWARNING
MUI_UNABORTWARNING_TEXT text
MUI_UNABORTWARNING_CANCEL_DEFAULT 3. PagesInsert the following macros to set the pages you want to use. The pages will appear in the order in which you insert them in the script. You can also insert custom Page commands between the macros to add custom pages. You can add multiple pages of certain types (for example, if you want the user to specify multiple folders). Examples: !insertmacro MUI_PAGE_LICENSE "License.rtf" !insertmacro MUI_PAGE_COMPONENTS Var StartMenuFolder !insertmacro MUI_PAGE_STARTMENU "Application" $StartMenuFolder You will need the page ID for the Start Menu folder page when using the Start Menu folder macros. The folder will be stored in the specified variable.
Installer pages
Uninstaller pages Page settingsPage settings apply to a single page and should be set before inserting a page macro. The same settings can be used for installer and uninstaller pages. You have to repeat the setting if you want it to apply to multiple pages. Example: ;Add a directory page to let the user specify a plug-ins folder ;Store the folder in $PluginsFolder Var PLUGINS_FOLDER !define MUI_DIRECTORYPAGE_VARIABLE $PluginsFolder !insertmacro MUI_PAGE_DIRECTORY
All standard texts in the user interface are loaded from language files, which are available for all languages supported by NSIS. So you only need to define these texts if you want to change the default. If the parameter is a text that should be different for each language, define a language string using LangString and use $(LangStringName) as value. For a license text in multiple languages, LicenseLangString can be used. Refer the NSIS Users Manual for more information about installers with multiple languages. In all text settings, the doublequote character (") should be escaped in the following form: $\" General page settings
MUI_PAGE_HEADER_TEXT text
MUI_PAGE_HEADER_SUBTEXT text Welcome page settings
MUI_WELCOMEPAGE_TITLE title
MUI_WELCOMEPAGE_TITLE_3LINES
MUI_WELCOMEPAGE_TEXT text License page settings
MUI_LICENSEPAGE_TEXT_TOP text
MUI_LICENSEPAGE_TEXT_BOTTOM text
MUI_LICENSEPAGE_BUTTON button_text
MUI_LICENSEPAGE_CHECKBOX
MUI_LICENSEPAGE_CHECKBOX_TEXT text
MUI_LICENSEPAGE_RADIOBUTTONS
MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT text
MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_DECLINE text Components page settings
MUI_COMPONENTSPAGE_TEXT_TOP text
MUI_COMPONENTSPAGE_TEXT_COMPLIST text
MUI_COMPONENTSPAGE_TEXT_INSTTYPE text
MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE text
MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO text Directory page settings
MUI_DIRECTORYPAGE_TEXT_TOP text
MUI_DIRECTORYPAGE_TEXT_DESTINATION text
MUI_DIRECTORYPAGE_VARIABLE variable
MUI_DIRECTORYPAGE_VERIFYONLEAVE Start Menu folder page settings
MUI_STARTMENUPAGE_TEXT_TOP text
MUI_STARTMENUPAGE_TEXT_CHECKBOX text
MUI_STARTMENUPAGE_DEFAULTFOLDER folder
MUI_STARTMENUPAGE_NODISABLE
MUI_STARTMENUPAGE_REGISTRY_ROOT root For the uninstaller, use the MUI_STARTMENU_GETFOLDER macro to get the Start Menu folder: !insertmacro MUI_STARTMENU_GETFOLDER page_id $R0 Delete "$SMPROGRAMS\$R0\Your Shortcut.lnk" Installation page settings
MUI_INSTFILESPAGE_FINISHHEADER_TEXT text
MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT text
MUI_INSTFILESPAGE_ABORTHEADER_TEXT text
MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT text Finish page settings
MUI_FINISHPAGE_TITLE title
MUI_FINISHPAGE_TITLE_3LINES
MUI_FINISHPAGE_TEXT text
MUI_FINISHPAGE_TEXT_LARGE
MUI_FINISHPAGE_BUTTON text
MUI_FINISHPAGE_CANCEL_ENABLED
MUI_FINISHPAGE_TEXT_REBOOT text
MUI_FINISHPAGE_TEXT_REBOOTNOW text
MUI_FINISHPAGE_TEXT_REBOOTLATER text
MUI_FINISHPAGE_REBOOTLATER_DEFAULT
MUI_FINISHPAGE_RUN exe_file
MUI_FINISHPAGE_RUN_TEXT text
MUI_FINISHPAGE_RUN_PARAMETERS parameters
MUI_FINISHPAGE_RUN_NOTCHECKED
MUI_FINISHPAGE_RUN_FUNCTION function
MUI_FINISHPAGE_SHOWREADME file/url
MUI_FINISHPAGE_SHOWREADME_TEXT text
MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
MUI_FINISHPAGE_SHOWREADME_FUNCTION function
MUI_FINISHPAGE_LINK link_text
MUI_FINISHPAGE_LINK_LOCATION file/url
MUI_FINISHPAGE_LINK_COLOR (color: RRGGBB hexadecimal)
MUI_FINISHPAGE_NOREBOOTSUPPORT Uninstall confirm page settings
MUI_UNCONFIRMPAGE_TEXT_TOP text
MUI_UNCONFIRMPAGE_TEXT_LOCATION text 4. Language filesInsert the Modern UI language files for the languages to want to include. !insertmacro MUI_LANGUAGE "English" The standard NSIS language files are loaded automatically, there is no need to use LoadLanguageFile. 5. Reserve filesIf you are using solid compression, files that are required before the actual installation should be stored first in the data block, because this will make your installer start faster. Include reserve file commands for such files before your sections and functions: ReserveFile MyPlugin.dll !insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog ... Script code for pagesSome pages allow you to show additional information or can be used to get user input. Here you can find the script code to use these features. Components page descriptionsThe Modern UI components page has a text box in which a description can be shown when the user hovers the mouse over a component. If you don't want to use these descriptions, insert the MUI_COMPONENTSPAGE_NODESC interface setting. To set a description for a section, an additional parameter needs to be added to Section commmand with a unique identifier for the section. This name can later be used to set the description for this section. Section "Section Name 1" Section1 ... SectionEnd After the sections, use these macros to set the descriptions: LangString DESC_Section1 ${LANG_ENGLISH} "Description of section 1." LangString DESC_Section2 ${LANG_ENGLISH} "Description of section 2." !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1) !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) !insertmacro MUI_FUNCTION_DESCRIPTION_END For the uninstaller, use the MUI_UNFUNCTION_DESCRIPTION_BEGIN and MUI_UNFUNCTION_DESCRIPTION_END macros. Start Menu folderPut the code to write the shortcuts (using CreateShortcut) between the MUI_STARTMENU_WRITE_BEGIN and MUI_STARTMENU_WRITE_END macros: !insertmacro MUI_STARTMENU_WRITE_BEGIN pageid ...create shortcuts... !insertmacro MUI_STARTMENU_WRITE_END The page ID should be the ID of the page on which the user has selected the folder for the shortcuts you want to write. The variable which contains the folder and the page ID are set as parameters of the page macro. Language selection dialogIf you want the installer to display a language selection dialog (see the the MultiLanguage.nsi example), insert the MUI_LANGDLL_DISPLAY macro in the .onInit function: Function .onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd This macro can also be used in the un.onInit function. Settings for registry storage of selected languageTo remember the user's preference, you can define a registry key. These defines should be set before inserting the installation page macro.
MUI_LANGDLL_REGISTRY_ROOT root For the uninstaller, insert the MUI_UNGETLANGUAGE macro in un.onInit to get the stored language preference: Function un.onInit !insertmacro MUI_UNGETLANGUAGE FunctionEnd Interface settings for selection dialogTo customize the language selection dialog interface, use these defines before inserting the MUI_LANGDLL_DISPLAY macro.
MUI_LANGDLL_WINDOWTITLE text
MUI_LANGDLL_INFO text
MUI_LANGDLL_ALWAYSSHOW
MUI_LANGDLL_ALLLANGUAGES Custom pagesIf you want add your custom pages to your installer, you can insert your own page commands between the page macros. !insertmacro MUI_PAGE_WELCOME Page custom FunctionName ;Custom page !insertmacro MUI_PAGE_COMPONENTS ;Uninstaller !insertmacro MUI_UNPAGE_CONFIRM UninstPage custom un.FunctionName ;Custom page !insertmacro MUI_UNPAGE_INSTFILES Use the MUI_HEADER_TEXT macro to set the text on the page header in a page function: LangString PAGE_TITLE ${LANG_ENGLISH} "Title" LangString PAGE_SUBTITLE ${LANG_ENGLISH} "Subtitle" Function CustomPageFunction !insermacro MUI_HEADER_TEXT $(PAGE_TITLE) $(PAGE_SUBTITLE) ... FuctionEnd Custom functionsInterface functions provided by NSIS, like the .onGUIInit function and the page functions are automatically included by the Modern UI and filled with code to support new interface features. If you want to add additional code to these function, create a function with the custom script code in the script use the Modern UI functions call them. Example: !define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit Function myGUIInit ... FunctionEnd Modern UI pages can also customized using custom functions. General Custom FunctionsThese defines should be set before inserting the language macros.
MUI_CUSTOMFUNCTION_GUIINIT function Mouse over functions are only available when the description macros (MUI_FUNCTION_DESCRIPTION_BEGIN) are used. When component page descriptions are not used, regular .onMouseOverSection and un.onMouseOverSection must be used. Page Custom FunctionsThese defines should be set before inserting a page macro.
MUI_PAGE_CUSTOMFUNCTION_PRE function The pre function is called first and allows you to initalize variables or decide whether the page should be skipped. Then, the show function is called, which can be used to customize the interface. Finally, the user input can be validated in the leave function. The NSIS Users Manual provides more information about these functions. In the show function, the window handles of all controls on the page can be retrieved from a Modern UI variable. A list of the variables names is not yet available. For now, refer to the source files of the Modern UI 2.0. The variable declarations can be found in the first lines of the header file for a certain page. Example scripts
Basic: Basic.nsi Credits
Written by Joost Verburg. LicenseThe zlib/libpng license applies to the Modern UI. License TermsCopyright © 2002-2009 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. |