Search code examples
nsis

How to change the Directory Destination folder text using NSIS?


I customized the directory destination folder text using the below code snippet in English.nsh file

!define MUI_TEXT_DIRECTORY_TITLE "Destination Folder"
!define MUI_TEXT_DIRECTORY_SUBTITLE "Click Install to install to the default folder or click Browse to choose another"

But I need to change the highlighted text that is showing as "Destination Folder" to "Install EMR to:"

Here the title should be as it is like how it is showing ("Destination Folder")

How to set the highlighted text (Destination Folder) to different text ("Install EMR to:")?

I followed the below link to fix the issue but even with that also i am getting the "Destination Folder" text two times.

Change the text of install folder page in NSIS

Below is my complete code:

CustomEngilish.nsh

    !define MUI_TEXT_DIRECTORY_TITLE "Destination Folder"
    !define MUI_TEXT_DIRECTORY_SUBTITLE "Click Install to install to the default folder or click Browse to choose another"
    !define MUI_DIRECTORYPAGE_TEXT_TOP "Install EMR to:"    
    !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Install EMR to:"

!insertmacro MUI_LANGUAGE "English"

Mysetup.nsi

!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyDirectoryShowCallback  
!insertmacro MUI_PAGE_DIRECTORY
!include "CustomEnglish.nsh"

    Function MyDirectoryShowCallback
    StrCpy $PageId 3
    SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_DIRECTORY_TITLE)"
    SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_DIRECTORY_SUBTITLE)"
    SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_DIRECTORYPAGE_TEXT_TOP)"
    SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_DIRECTORYPAGE_TEXT_DESTINATION)"
    
    FunctionEnd

Solution

  • MUI_TEXT_DIRECTORY_TITLE is the text in the top header, you want MUI_DIRECTORYPAGE_TEXT_TOP and it needs to point to a custom language string when using multiple languages:

    !include "MUI2.nsh"
    !insertmacro MUI_PAGE_WELCOME
    !define MUI_DIRECTORYPAGE_TEXT_TOP $(mydirtoptext)
    !insertmacro MUI_PAGE_DIRECTORY
    !insertmacro MUI_PAGE_INSTFILES
    
    ; CustomSwedish.nsh:
    !insertmacro MUI_LANGUAGE "Swedish"
    LangString mydirtoptext ${LANG_SWEDISH} "Swedish bork bork"
    
    ; CustomEnglish.nsh:
    !insertmacro MUI_LANGUAGE "English"
    LangString mydirtoptext ${LANG_ENGLISH} "English blah blah"
    

    In your screenshot the top area is gray but it should normally be white, this often indicates a problem with the order of your MUI_PAGE and MUI_LANGUAGE macros. All languages must come after the pages.