Archive: Header Text / MUI2 / nsDialogs


Header Text / MUI2 / nsDialogs
Hi,

I just created my first installer using NSIS. I just can't set header text nor header image.
I tried:
!define MUI_PAGE_HEADER_TEXT "Title"
or
!insertmacro MUI_HEADER_TEXT "Title" "Subtitle"

but there's still an empty header bar.

What I'm doing wrong?


Var DotnetInstalled         ; if OK no need to install

;/////////
; INCLUDES
;/////////

!include LogicLib.nsh ; Use more familiar flow control
!include "MUI2.nsh"
!include "x64.nsh" ; For using {RunningX64}
!include "DotNetVer.nsh" ; for ${HasDotNet4.0}
!include "nsDialogs.nsh" ; To create labels on a custom page

Name "MeetVideo DeskShare"
OutFile "MeetVideo DeskShare Setup.exe"
InstallDir "$PROGRAMFILES\MeetVideo DeskShare"
InstallDirRegKey HKLM "Software\MeetVideo_DeskShare" "Install_Dir"
RequestExecutionLevel admin


;--------------------------------
;Interface Configuration
!define MUI_PAGE_HEADER_TEXT "MeetVideo"
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN "$INSTDIR\DeskShare.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Start MeetVideo DeskShare"
;--------------------------------

; Pages

Page custom Welcome
Page custom CheckAndInstallDotNet "" ": .Net Framework"
page custom CheckAndInstallVcRedist "" ": VC++ Redistributable"

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH




!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES


;--------------------------------

; The stuff to install
Section "DeskShare (required)"

SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File /r "IncludeFiles\*.*"

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\MeetVideo_DeskShare "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DeskShare" "DisplayName" "MeetVideo DeskShare"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DeskShare" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DeskShare" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DeskShare" "NoRepair" 1
WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

CreateDirectory "$SMPROGRAMS\MeetVideo DeskShare"
CreateShortCut "$SMPROGRAMS\MeetVideo DeskShare\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\MeetVideo DeskShare\DeskShare.lnk" "$INSTDIR\DeskShare.exe" "" "$INSTDIR\DeskShare.exe" 0

SectionEnd

Section "Desktop Shortcut"
CreateShortCut "$DESKTOP\MeetVideo DeskShare\DeskShare.lnk" "$INSTDIR\DeskShare.exe" "" "$INSTDIR\DeskShare.exe" 0
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DeskShare"
DeleteRegKey HKLM SOFTWARE\MeetVideo_DeskShare

; Remove files and uninstaller
Delete $INSTDIR\*.*
;Delete $INSTDIR\uninstall.exe

; Remove shortcuts, if any
Delete "$SMPROGRAMS\MeetVideo DeskShare\*.*"

; Remove directories used
RMDir "$SMPROGRAMS\MeetVideo DeskShare"
RMDir "$INSTDIR"

SectionEnd


Function Welcome
!insertmacro MUI_HEADER_TEXT "Title" "Subtitle"
nsDialogs::Create 1018 ;Create a Dialog Window


${NSD_CreateLabel} 0 0 100% 12u "MeetVideo DeskShare is an aplication for capturing and sharing desktop screen."
${NSD_CreateLabel} 0 24u 100% 12u "Following prerequisities will be installed if not present:"
${NSD_CreateLabel} 12u 36u 100% 12u ".NET Framework 4"
${NSD_CreateLabel} 12u 48u 100% 12u "VC++ Redistibutable"

${NSD_CreateLabel} 0 90% 100% 12u "(c) Copyright 2012, MONOGRAM Technologies. All rights reserved."
nsDialogs::Show
FunctionEnd

Function CheckAndInstallDotNet
nsDialogs::Create 1018 ;Create a Dialog Window
${NSD_CreateLabel} 0 0 100% 10% "Checking for .NET Framework 4.0 on your system ..."
;Check the DotNet Version
Call CheckDotNetFramework
; Install .net if not present
${If} $DotnetInstalled == ""
${NSD_CreateLabel} 0 40 100% 30u "Your System does not have .Net Framework 4.0 installed. \
Please click 'Next' to install the .Net Framework ..."
nsDialogs::Show ; show the dialog window
Call InstallDotNet
${Else}
${NSD_CreateLabel} 0 40 100% 30u "Your System has the required .Net Framework already installed. Please click Next \
to continue this installation."
nsDialogs::Show
${EndIf}
FunctionEnd

Function CheckDotNetFramework
${If} ${HasDotNet4.0}
Push "Microsoft .NET Framework 4.0 installed."
Pop $DotnetInstalled
${Else}
Push ""
Pop $DotnetInstalled
${EndIf}
FunctionEnd

Function InstallDotNet
SetOutPath '$TEMP'
SetOverwrite on
;file work UNDO to save time in debugging
File 'DeploymentResources\dotNetFx40_Client_x86_x64.exe'
ExecWait '"$TEMP\dotNetFx40_Client_x86_x64" /norestart'
Delete "$TEMP\dotNetFx40_Client_x86_x64.exe"
FunctionEnd

Function CheckAndInstallVcRedist
nsDialogs::Create 1018 ;Create a Dialog Window
${NSD_CreateLabel} 0 0 100% 30u "Checking for VC 2010 C++ Redistributable ..."
Call CheckVCRedist
StrCmp $R0 "-1" 0 +4
${NSD_CreateLabel} 0 40 100% 30u "Installing VC 2010 C++ Redistributable..."
Call InstallVcRedist
Goto +2
${NSD_CreateLabel} 0 40 100% 30u "VC 2010 C++ Redistributable already installed. \
Please click next to continue installation"
nsDialogs::Show ;show the dialog window
FunctionEnd

Function CheckVCRedist
; check for 2 possible keys in registry, if any one is good,
; the distributable has already been installed:

ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" "Installed"
${If} $R0 == 1
return
${Else}
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" "Installed"
${If} $R0 == 1
return
${Else}
StrCpy $R0 "-1"
${EndIf}
${EndIf}
FunctionEnd


; install Visual Studio 2010 C++ redistributable
Function InstallVcRedist
SetOutPath '$TEMP'
SetOverwrite on
;file work
File 'DeploymentResources\vcredist_x86.exe'
ExecWait '"$TEMP\vcredist_x86.exe" /norestart'
Delete "$TEMP\vcredist_x86.exe"
FunctionEnd



No language macros?


I have created my first installer and need to add a new page before the FINISH page. Objective is to ask for directory location where a specific file(exe file of another application) is located. Based on the location entered, I need to pass this as a parameter to run a program. I am new to NSIS and having hard time creating a new page by myself. Here is the code I am using:


; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "myfirstapp"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "Company XYZ"
!define PRODUCT_WEB_SITE "http://www.companyxyz.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "Software_License.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\myfirstapp"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR\config"
SetOverwrite try
File "config\firstfile.xsl"
File "config\second.xsl"
File "config\fav.jpg"
File "config\favicon.ico"
SetOutPath "$INSTDIR\config\fonts\fonts"
File "config\fonts\fonts\CALIBRI.TTF"
File "config\fonts\fonts\CALIBRI.xml"
File "config\fonts\fonts\CALIBRIB.TTF"
File "config\fonts\fonts\CALIBRIB.xml"
File "config\fonts\fonts\CALIBRII.TTF"
File "config\fonts\fonts\CALIBRII.xml"
File "config\fonts\fonts\CALIBRIZ.TTF"
File "config\fonts\fonts\CALIBRIZ.xml"
File "config\fonts\fonts\times.ttf"
File "config\fonts\fonts\times.xml"
File "config\fonts\fonts\timesbd.ttf"
File "config\fonts\fonts\timesbd.xml"
File "config\fonts\fonts\timesbi.ttf"
File "config\fonts\fonts\timesbi.xml"
File "config\fonts\fonts\timesi.ttf"
File "config\fonts\fonts\timesi.xml"
SetOutPath "$INSTDIR\config"
File "config\helper.xml"
CreateDirectory "$SMPROGRAMS\myfirstapp"
CreateShortCut "$SMPROGRAMS\myfirstapp\Help.lnk" SetOutPath "$INSTDIR"
File "myfirstapp.jar"
CreateShortCut "$DESKTOP\myfirstapp.lnk" "$INSTDIR\myfirstapp.jar" " " "$INSTDIR\config\favicon.ico"
File "Software_License.txt"
SectionEnd

Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\myfirstapp\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe" RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd


How is this question related to the original post?


Sorry, i am new to this forum and could not find link to start new thread. Instead I saw this thread is related to custom page.


@Anders:
how languages macros are related to the header text?


When using MUI, you must include at least one language.


@Liero

Use this macro:
!insertmacro MUI_HEADER_TEXT_PAGE "Text" "Subtext"