Archive: Configuring the finish page


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

WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "-10"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "142"

WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Right" "-10"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Top" "144"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Bottom" "156"

Your top values were the same so one would surely have been under another!

Stu


Weird, it still displayed everything perfectly though. I've used your code instead. However, if you comment out the following three lines of code along with the function call we lose the "Launch Application" checkbox (which i need to do sometimes). Therefore you get the 3 checkboxes but not underneath each other.


!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch Application"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApp"


This is what I do not understand:

I don't know for sure what the left, right, top and bottom values stand for. For example if we have the values 120,-10,130,142 respectively at a guess a checkbox is 120 in from the left of the frame but what does the -10 stand for? Similarly 130 down from the top but does the 156 stand for?

It doesn't make sense to have 4 values because all you need to position anything is x and y.

How do I change the values of the bottom 2 checkboxes to get the three of them underneath each other with equal spacing?

I've been playing around with it and it doesn't make any sense.

Regards

Paul

Typo:

This "but does the 156 stand for?" should be this "but does the 142 stand for?"


Think of the figures as dialog units. Positive is from the top or left and negative is from the bottom or right.

It's confusing at first but right=-10 sets the right position of a control/field to -10 units from the right hand side of the dialog. right=50 would put the right hand side to be 50 units from the left of the dialog.

Stu