Use 2 welcome/finish page images in nsis - installation

I am using this code to change the MUI_WELCOMEFINISH_BITMAP, text and title of the welcome page.
Function MyWelcomeShowCallback
SendMessage $mui.WelcomePage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_WELCOME_INFO_TEXT)$\n$\nVersion: foo.bar"
FunctionEnd
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\bg2_2.bmp"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_WELCOMEPAGE_TITLE "Title"
!define MUI_WELCOMEPAGE_TEXT "Text"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyWelcomeShowCallback
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
I wanted to change the bitmap twice, once for welcome and once for finish page. Unfortunately !define MUI_WELCOMEFINISHPAGE_BITMAP $bmp can only be used once. I know that it is possible to change bmp path in Welcome.nsh, but I'd rather define everything in .nsi script. How can I set differenet images for welcome and finish page? In essence, how does one change the value if !defined was used to create it.

There is no define you can set to use different images but you can overwrite the image before the page is displayed:
Function ForceWizard1
SetOverWrite on
File "/oname=$PLUGINSDIR\modern-wizard.bmp" "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp"
SetOverWrite lastused
FunctionEnd
Function ForceWizard2
SetOverWrite on
File "/oname=$PLUGINSDIR\modern-wizard.bmp" "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
SetOverWrite lastused
FunctionEnd
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_PRE ForceWizard1
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_PRE ForceWizard2
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English

Related

How to change default NSIS logo and also add an shortcut to desktop?

I tried changing my logo but the following error occurs:!define: "MUI_INSERT_NSISCONF" already defined!
I'm very new to NSIS.Sorry if this is a silly question for you.
To create a shortcut on a Desktop for the current user:
CreateShortCut "$DESKTOP\Filename.lnk" "$INSTDIR\SomeFile.exe" "<Optional Command Line>"
To change the icon and logo:
!include "MUI2.nsh"
!define MUI_ICON "MyApp.ico"
!define MUI_UNICON "MyApp.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "InstallerLogo.bmp"

NSIS MUI_PAGE_HEADER_TEXT not showing

NSIS newbie here. Using nsis v2.51 with MUI2 (Modern UI 2)
As stated, my problem is that even though I set the MUI_PAGE_HEADER_TEXT define, the resulting installer does not show any text at all where it should be. The same happens for MUI_PAGE_HEADER_SUBTEXT. However, page specific text defines show correctly.
This is the minimal NSIS script that demonstrates the issue:
Name "Just for show"
OutFile "MuiText.exe"
!include "MUI2.nsh"
!define MUI_PAGE_HEADER_TEXT "AAAAAAA"
!define MUI_PAGE_HEADER_SUBTEXT "CHANGE MEEEEEEE! CHANGE MEEEEEEE!!!!"
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the directory where you want this fine program installed."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Enter Directory"
!insertmacro MUI_PAGE_DIRECTORY
Section
SectionEnd
And this is the screenshot of the resulting installer:
Any ideas on how can I make the text show up? Thank you.
You must specify at least one language with MUI_LANGUAGE otherwise the UI does not work correctly:
!include "MUI2.nsh"
!define MUI_PAGE_HEADER_TEXT "AAAAAAA"
!define MUI_PAGE_HEADER_SUBTEXT "CHANGE MEEEEEEE! CHANGE MEEEEEEE!!!!"
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the directory where you want this fine program installed."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Enter Directory"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

NSD_GetState returns 0 always: NSIS

I was trying to include a check box in my uninstaller. I was able to put the check box in place. But when I try to get the state of check box it always returns 0 even though check box is checked. Here is the code I am using
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_FINISH
Function un.ModifyUnWelcome
${NSD_CreateCheckbox} 120u -18u 50% 25u "Do something special"
Pop $mycheckbox
SetCtlColors $mycheckbox "" ${MUI_BGCOLOR}
${NSD_Check} $mycheckbox ; Check it by default
FunctionEnd
Function un.LeaveUnWelcome
${NSD_GetState} $mycheckbox $0
MessageBox MB_OK "On Leave mycheckbox = $mycheckbox $\n $$0 = $0"
${If} $0 <> 0
MessageBox mb_ok "I'm special"
${EndIf}
FunctionEnd
As a result I could not verify if the check box is checked or not.
what is wrong with my code and how can I fix it?
I even tried something like below
${NSD_Check} $mycheckbox ; Check it by default
${NSD_SetState} $mycheckbox ${BST_CHECKED}
I got the above code from Adding a checkbox to the NSIS Uninstaller Welcome Page
Your custom functions referred to two different pages.
ModifyUnWelcome is calling when creates MUI_UNPAGE_WELCOME page, LeaveUnWelcome - when user leaves last MUI_UNPAGE_FINISH page.
Control, owned by handle at ModifyUnWelcome will be destroyed at the moment when you are calling ${NSD_GetState}. You should to place custom functions definitions near each other and before referred page declaration.
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!insertmacro MUI_UNPAGE_FINISH

Change the text of install folder page in NSIS

I need to change the text on the "Choose Install Location" page of an NSIS installer to say that my program can not be installed in a directory containing spaces in the name.
What is the best way to change this text?
!include MUI2.nsh
!define MUI_PAGE_HEADER_TEXT Foo
!define MUI_PAGE_HEADER_SUBTEXT Bar
!define MUI_DIRECTORYPAGE_TEXT_TOP Baz
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION Bob
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
You might also want to check the path when the user is about to leave the page (In the page leave callback)...

How can I modify the text in the MUI_WELCOME_PAGE when using MUI2 for NSIS?

I want to add a label displaying the full version-string in the welcome screen in the installer I am creating using NSIS with MUI2.
I have searched for info on how to do this, but only found references to using MUI_INSTALLOPTIONS* which I found ws deprecated for MUI2. Another one referred to the newer versions using INSTALLOPTIONS* with the same options, but I could not get it working. I finally also found a reference to using nsDialogs for this - which is what I am using for my custom pages. However - I found no reference or samples on how to change any of the existing pages that comes with MUI2.nsh.
I found a way to change the MUI_HEADERTEXT, but that doesn't affect the welcome-screen. I wish there was a way to also change the welcometext. Maybe using MUI_WELCOMETITLE and MUI_WELCOMEBODY or similar.
There is MUI_WELCOMEPAGE_TEXT but it is only useful if you want to change all of the text and not just append something.
During the show function for the page, you can change the text of any control:
outfile test.exe
requestexecutionlevel user
!include MUI2.nsh
#!define MUI_WELCOMEPAGE_TEXT "New text goes here"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyWelcomeShowCallback
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function MyWelcomeShowCallback
SendMessage $mui.WelcomePage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_WELCOME_INFO_TEXT)$\n$\nVersion: foo.bar"
FunctionEnd
Section
SectionEnd
..or add a new control:
outfile test.exe
requestexecutionlevel user
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyWelcomeShowCallback
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function MyWelcomeShowCallback
${NSD_CreateLabel} 120u 150u 50% 12u "Version: foo.bar"
Pop $0
SetCtlColors $0 "" "${MUI_BGCOLOR}"
FunctionEnd
Section
SectionEnd
I also had the issue with NSIS. In my case it worked to define MUI_WELCOMEPAGE_TITLE before inserting the macro MUI_PAGE_WELCOME.
It should look like:
!define MUI_WELCOMEPAGE_TITLE "CUSTOM TITLE HERE"
!insertmacro MUI_PAGE_WELCOME

Resources