How to set a default language on select language dialog? - nsis

I have my .nis like this:
## Languages (first language is the default language)
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Dutch"
I read the manual and it says:
first language is the default language
If I don't use English that works correctly, if I use English that is always the default language:
How I can change the default language?

There are 3 steps involved in selecting the default language for the language picker dialog.
At startup NSIS tries to initialize $Language with the language id of the UI language the user is using. This happens before the .onInit callback is called.
If you are using the MUI and have set the MUI_LANGDLL_REGISTRY_* defines and they are found in the registry then $Language is forced to that language in the MUI_LANGDLL_DISPLAY macro. Remove the defines if you don't want this behavior or define MUI_LANGDLL_ALWAYSSHOW to let the user override it.
The LangDLL plugin will filter out some of the languages if it thinks there is a codepage problem (in ANSI installers). This can be turned off by defining MUI_LANGDLL_ALLLANGUAGES.
If you want to ignore step 1 then you have to force the language on your own:
Function .onInit
StrCpy $Language ${LANG_FRENCH}
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Related

write in header section of custom installer page (without MUI)

I used this guide to create custom page in my installer:
nsDialogs
and its working without a problem, this is the code:
!include nsDialogs.nsh
!include LogicLib.nsh
XPStyle on
Var Dialog
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
...
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
...
FunctionEnd
Section
SectionEnd
But the only thing missing is this part:
Could someone help me out and show how to add text there, but without this MUI, all the guides i tried to find are refering to the MUI way but i went with Pages instead so i would like to keep it that way, surely there is a way. Thank you in advance!
Your screenshot looks like MUI. Even when using MUI, custom pages still use Page Custom ....
The MUI has a helper macro to set the text on the top for your custom pages:
!include MUI2.nsh
...
Function nsDialogsPage
!insertmacro MUI_HEADER_TEXT "Blah" "Blah blah"
nsDialogs::...
...
FunctionEnd
This macro is documented in the MUI readme. It is not in the nsDialogs documentation because these labels are in the outer dialog, not in the inner page dialog.
In the unlikely event that you are not using MUI (but you are using the MUI dialog layout and ChangeUI) you can copy the MUI_HEADER_TEXT macro from the MUI(v1) source file or write your own custom macro based on the MUI source.

How do I make only some sections readonly for a section group in NSIS?

I have a section group, and in this group I have 4 sections.
What I want: make only the first two section readonly for the group, and leave the rest optional, in the uninstall part.
My code is the following:
Function un.onInit
!insertmacro SetSectionFlag ${firstUnSec} ${SF_RO}
!insertmacro SetSectionFlag ${secondUnSec} ${SF_RO}
FunctionEnd
SectionGroup "What to delete" groupsec
Section "un.First part" firstUnSec
Call "un.DropFirst"
SectionEnd
Section "un.Second part" secondUnSec
Call "un.DropSecond"
SectionEnd
Section "un.Third part" thirdUnSec
Call "un.DropThird"
SectionEnd
Section "un.Forth part" forthUnSec
Call "un.DropForth"
SectionEnd
SectionGroupEnd
But it makes only the group readonly, and every section inside the group are optional! Why is that?
Thanks!
Code that uses the section index must come after the section itself in the .NSI file.
SectionGroup "What to delete" groupsec
Section "un.First part" firstUnSec
Call "un.DropFirst"
SectionEnd
SectionGroupEnd
Function un.onInit
!insertmacro SetSectionFlag ${firstUnSec} ${SF_RO}
FunctionEnd
You don't need any code if it's always read only, you can set the section attribute at compile-time:
SectionGroup "What to delete" groupsec
Section "un.First part" firstUnSec
SectionIn RO
Call "un.DropFirst"
SectionEnd
SectionGroupEnd

Change default buttons name NSIS

I am very new to NSIS,
I created a simple installer with 2 screens,
!include LogicLib.nsh
!include nsDialogs.nsh
Page custom someName someEndmethod
Page instfiles
First one is a custom page (nsDialogs) and on it the default button is "install" and i have 2 questtions :
How do i bound a method to its click event ?
How do i change the text on that button ?
BTW - I am not using MUI .
The best reference i could found regarding the nsDialogs was the following:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
but could not seem to find answer to those simple questions.
Thanks
!include WinMessages.nsh
Function MyPageCreate
GetDlgItem $0 $hwndparent 1 ; Get the handle to the button
SendMessage $0 ${WM_SETTEXT} 0 `STR:$(^NextBtn)` ; The part after STR: can be any string, using the next button language string here
nsDialogs::Create 1018
pop $0
nsDialogs::Show
FunctionEnd
Function MyPageLeave
MessageBox mb_yesno "User clicked Next/Install, allow the page change?" IDYES allow
Abort
allow:
FunctionEnd
Page Components
Page Custom MyPageCreate MyPageLeave
Page InstFiles
If you just want to change the string on the install button no matter which page it is on (The page before the instfiles page) you can change it with LangString instead.

How can I add a header to the NSIS license page?

The top of my NSIS license page looks rather stark:
I don't see any way to modify the header/subtitle of the page through the normal channels. LicenseText looks close, but it only seems to modify the text at the bottom of the dialog.
Is there any way to add a header to the page?
You must include a language to fully initialize the MUI:
!include "MUI.nsh"
!insertmacro MUI_PAGE_LICENSE "License.rtf"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_...
!insertmacro MUI_LANGUAGE "English"
If you want to use a bitmap in the header and not the .exe icon, then you should look at the defines Seki talks about...
If you are using the Modern UI, define MUI_HEADERIMAGE_BITMAP to the path of an image (you can see in the MUI documentation.
You have an example in the script HeaderBitmap.nsi that comes with MUI2.

Calling PRE functions of MUI in NSIS installer, skipping pages/dialogs in NSIS installer

Can PRE function of a MUI dialog be called only when required?
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipComponentsPage
!insertmacro MUI_PAGE_COMPONENTS
Function SkipComponentsPage
Abort
MessageBox MB_OK "You chose to UPDATE your current version"
FunctionEnd
//This section will be checked by default, that is , user will not be able to select or unselect this section , this has to be executed..........how to do this?To hide it , i have included a - sign in its name. its name is "mandatory"
Section "-mandatory" SEC_UPDATE
#Do update............
SectionEnd
I have two RadioButtons (Demo & Update) on my custom dialog page in the NSIS installer.
I want that when the user choses to install the UPDATE (choses the UPDATE RadioButton), then the Components Page is skipped , and a specified Section is auto CHECKED and executed.
But if the user choses to install the DEM (choses the DEMO RadioButton) , then the Components page is not skipped & the user can Check or Uncheck Sections on that Component page.
A page callback is always called, but you can put logic inside the function:
...
section "" SEC_UPDATE
sectionend
Function SkipComponentsPage
!insertmacro UnSelectSection ${SEC_UPDATE} ; Don't include update with demo by default?
${If} $InstallType == UPDATE
!insertmacro SelectSection ${SEC_UPDATE}
Abort
${EndIf}
Functionend
It is not really clear to me if you want the user to be able to choose update in the demo mode, but if you want to force the update you can make the section read only:
section "Update" SEC_UPDATE
SectionIn RO
sectionend
(And remove the UnSelectSection call from the pre function)
...or just make the section invisible with the -name prefix like you suggested.

Resources