Configuring the finish page
Hi
I wish to configure the finish page so it has four checkboxes.
I've taken the code from the forum and docs.
;NSIS Modern User Interface
;Welcome/Finish Page Example Script
;Written by Joost Verburg
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;--------------------------------
;General
;Name and file
Name "Modern UI Test"
OutFile "WelcomeFinish.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\Modern UI Test"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\Modern UI Test" ""
;--------------------------------
;Interface Settings
;--------------------------------
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico"
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
;--------------------------------
;Pages
;--------------------------------
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;------------------------------
; Finish Page
;------------------------------
; 2 Checkboxes for Quick launch and Desktop.
!define MUI_PAGE_CUSTOMFUNCTION_PRE CreateControls
!define MUI_PAGE_CUSTOMFUNCTION_SHOW SetControlColours
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DisplayQuickLaunchAndDesktopIcon
; 1 Checkbox for release notes.
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Release Notes"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReleaseNotes
; 1 Checkbox to launch the app.
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch Application"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApp"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE...
;Store installation folder
WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
SectionEnd
;-----------------------------------------------------------------
; The following two functions CreateControls & SetControlColours
; are editing the ini file at runtime so we can add the two
; additional check boxes.
;-----------------------------------------------------------------
Function CreateControls
; Quicklaunch short cut.
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Text" "&Create Quick Launch Shortcut"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "140"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "State" "1"
; Desktop short cut.
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "7"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Text" "&Create Desktop Shortcut"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Bottom" "180"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "State" "1"
FunctionEnd
Function SetControlColours
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
FunctionEnd
Function LaunchApp
;MessageBox MB_OK "Deal with launching application"
FunctionEnd
Function ShowReleaseNotes
;MessageBox MB_OK "Deal with release notes"
FunctionEnd
Function DisplayQuickLaunchAndDesktopIcon
;ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
;StrCmp $0 "0" end
; CreateShortCut ...
;end:
;ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
;StrCmp $0 "0" finish
; CreateShortCut ...
;finish:
FunctionEnd
The layout is fine and it all looks great.
The problem is should I need to remove one of the check boxes (e.g. Launch Application) Then I can't seem to position the remaining check boxes neatly despite trying all sorts of positioning permutations.
Is this the correct way to go? Is there an easier way to do things?
Regards
Paul