View Single Post
Old 29th April 2017, 09:44   #1
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 48
Select aditional components

This post shows you how to select multiple files on the component page

PHP Code:
!define APP "My Setup"
!define INIT
!define MULTILANG
!define LANGDIR "Language"
!define COMPONENTS

# DETAILS #

Name "${APP}"
OutFile "${APP}.exe"
InstallDir "$TEMP\${APP}"
Caption "${APP}"

# COMPRESS #

SetCompressor /SOLID /FINAL lzma

# EXEC LEVEL #

RequestExecutionLevel 'User'

# RUNTIME SWITCHES #

ShowInstDetails hide
ShowInstDetails nevershow
ShowUnInstDetails nevershow
AutoCloseWindow true 

# INCLUDE #

!include "MUI.nsh"
!include "WinCore.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!insertmacro GetOptions

# STYLE #

BrandingText /TRIMRIGHT " "

# PAGE #

!define MUI_CUSTOMFUNCTION_GUIINIT "onGuiInit"
!insertmacro MUI_PAGE_WELCOME
!ifdef OPTIONS COMPONENTS MULTILANG
  
!define MUI_COMPONENTSPAGE_NODESC
  
!define MUI_COMPONENTSPAGE_INTERFACE
  
!define MUI_COMPONENTSPAGE_SMALLDESC
  
!insertmacro MUI_PAGE_COMPONENTS
!endif
!
insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

# LANGUAGE #

!insertmacro MUI_LANGUAGE "English"

# INIT #

Function ".onInit"

  
# INIT
 
  
!ifdef INIT
    Call Init
  
!endif

  
# INIT
 
  
!ifdef MULTILANG
    Call MultiLang
  
!endif

FunctionEnd

Function "onGuiInit"

FunctionEnd

var /GLOBAL ERROR

Section 
"-${APP}Main

  SetDetailsPrint textonly
  DetailPrint 
`Installing ... Please wait ...`
  
SetDetailsPrint listonly
  SetDetailsView hide

  SectionIn RO

  CreateDirectory $INSTDIR
    SetOutPath 
"$INSTDIR"
     
File "Installer.nsi"

  
Goto +2
   StrCpy $ERROR 
"true"
  
SetAutoClose true
SectionEnd

!ifdef COMPONENTS
    SectionGroup 
"${APP} Select"

      
Section /"${APP} Free" Free

      SectionEnd

      Section 
/"${APP} Professional" Professional
        IfFileExists 
"$INSTDIR\${APP}.exe" "" +4
            SetOutPath 
"$INSTDIR"
                
;File "Professional\Register.dll"
      
SectionEnd

    SectionGroupEnd
!endif

!
ifdef MULTILANG
    SectionGroup 
"Language"
        
Section /"Albanian" albanian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Albanian.lng"
        
SectionEnd
        Section 
/"Arabic" arabic
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Arabic.lng"
        
SectionEnd
        Section 
/"Belarusian" belarusian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Belarusian.lng"
        
SectionEnd
        Section 
/"Bulgarian" bulgarian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Bulgarian.lng"
        
SectionEnd
        Section 
/"SimpChinese" simpChinese
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\ChineseSimp.lng"
        
SectionEnd
        Section 
/"TradChinese" tradChinese
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\ChineseTrad.lng"
        
SectionEnd
        Section 
/"Croatian" croatian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Croatian.lng"
        
SectionEnd
        Section 
/"Czech" czech
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Czech.lng"
        
SectionEnd
        Section 
/"Danish" danish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Danish.lng"
        
SectionEnd
        Section 
/"Dutch" dutch
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Dutch.lng"
        
SectionEnd
        Section 
"English" english
            SectionIn RO
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\English.lng"
        
SectionEnd
        Section 
/"Finnish" finnish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Finnish.lng"
        
SectionEnd
        Section 
/"French" french
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\French.lng"
        
SectionEnd
        Section 
/"German" german
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\German.lng"
        
SectionEnd
        Section 
/"Greek" greek
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Greek.lng"
        
SectionEnd
        Section 
/"Hebrew" hebrew
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Hebrew.lng"
        
SectionEnd
        Section 
/"Hungarian" hungarian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Hungarian.lng"
        
SectionEnd
        Section 
/"Italian" italian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Italian.lng"
        
SectionEnd
        Section 
/"Japanese" japanese
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Japanese.lng"
        
SectionEnd
        Section 
/"Korean" korean
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Korean.lng"
        
SectionEnd
        Section 
/"Mongolian" mongolian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Mongolian.lng"
        
SectionEnd
        Section 
/"Nepali" nepali
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Nepali.lng"
        
SectionEnd
        Section 
/"Polish" polish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Polish.lng"
        
SectionEnd
        Section 
/"Portuguese" Portuguese
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Portuguese (PT-PT).lng"
        
SectionEnd
        Section 
/"PortugueseBR" portugueseBr
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Portuguese (PT-BR).lng"
        
SectionEnd
        Section 
/"Romanian" romanian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Romanian.lng"
        
SectionEnd
        Section 
/"Russian" russian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Russian.lng"
        
SectionEnd
        Section 
/"Serbian" serbian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Serbian (Cyrillic).lng"
        
SectionEnd
        Section 
/"SerbianLatin" serbianLatin
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Serbian (Latin).lng"
        
SectionEnd
        Section 
/"Slovenian" slovenian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Slovenian.lng"
        
SectionEnd
        Section 
/"Spanish" spanish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Spanish.lng"
        
SectionEnd
        Section 
/"Swedish" swedish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Swedish.lng"
        
SectionEnd
        Section 
/"Thai" thai
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Thai.lng"
        
SectionEnd
        Section 
/"Turkish" turkish
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Turkish.lng"
        
SectionEnd
        Section 
/"Ukrainian" ukrainian
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Ukrainian.lng"
        
SectionEnd
        Section 
/"Vietnamese" vietnamese
            SetOutPath 
"$INSTDIR\${LANGDIR}"
                
;File "${LANGDIR}\Vietnamese.lng"
        
SectionEnd
    SectionGroupEnd

    
Function MultiLang
        
; === Automatically select language with the same language of Windows language ===
        
System::Call `kernel32::GetUserDefaultLangID() i .r0`
        
StrCmp $"1025" "" +2
            SectionSetFlags 
${arabic1
        StrCmp 
$"1026" "" +2
            SectionSetFlags 
${bulgarian1
        StrCmp 
$"1028" "" +2
            SectionSetFlags 
${tradChinese1
        StrCmp 
$"1029" "" +2
            SectionSetFlags 
${czech1
        StrCmp 
$"1030" "" +2
            SectionSetFlags 
${danish1
        StrCmp 
$"1031" "" +2
            SectionSetFlags 
${german1
        StrCmp 
$"1032" "" +2
            SectionSetFlags 
${greek1
        StrCmp 
$"1033" "" "" English
            SectionSetFlags 
${English1
        StrCmp 
$"1034" "" +2
            SectionSetFlags 
${spanish1
        StrCmp 
$"1035" "" +2
            SectionSetFlags 
${finnish1
        StrCmp 
$"1036" "" +2
            SectionSetFlags 
${french1
        StrCmp 
$"1037" "" +2
            SectionSetFlags 
${hebrew1
        StrCmp 
$"1038" "" +2
            SectionSetFlags 
${hungarian1
        StrCmp 
$"1040" "" +2
            SectionSetFlags 
${italian1
        StrCmp 
$"1041" "" +2
            SectionSetFlags 
${japanese1
        StrCmp 
$"1042" "" +2
            SectionSetFlags 
${korean1
        StrCmp 
$"1043" "" +2
            SectionSetFlags 
${dutch1
        StrCmp 
$"1045" "" +2
            SectionSetFlags 
${polish1
        StrCmp 
$"1046" "" +2
            SectionSetFlags 
${portugueseBr1
        StrCmp 
$"1048" "" +2
            SectionSetFlags 
${romanian1
        StrCmp 
$"1049" "" +2
            SectionSetFlags 
${russian1
        StrCmp 
$"1050" "" +2
            SectionSetFlags 
${croatian1
        StrCmp 
$"1052" "" +2
            SectionSetFlags 
${albanian1
        StrCmp 
$"1053" "" +2
            SectionSetFlags 
${swedish1
        StrCmp 
$"1054" "" +2
            SectionSetFlags 
${thai1
        StrCmp 
$"1055" "" +2
            SectionSetFlags 
${turkish1
        StrCmp 
$"1058" "" +2
            SectionSetFlags 
${ukrainian1
        StrCmp 
$"1059" "" +2
            SectionSetFlags 
${belarusian1
        StrCmp 
$"1060" "" +2
            SectionSetFlags 
${slovenian1
        StrCmp 
$"1066" "" +2
            SectionSetFlags 
${Vietnamese1
        StrCmp 
$"1104" "" +2
            SectionSetFlags 
${mongolian1
        StrCmp 
$"1121" "" +2
            SectionSetFlags 
${nepali1
        StrCmp 
$"2052" "" +2
            SectionSetFlags 
${simpChinese1
        StrCmp 
$"2070" "" +2
            SectionSetFlags 
${portuguese1
        StrCmp 
$"2074" "" +2
            SectionSetFlags 
${serbianLatin1
        StrCmp 
$"3098" "" +2
            SectionSetFlags 
${serbian1
    FunctionEnd
!endif

Function .
onSelChange
    
!insertmacro StartRadioButtons $1
    
!insertmacro RadioButton "${Free}"
    
!insertmacro RadioButton "${Professional}"
    
!insertmacro EndRadioButtons
FunctionEnd

!ifdef INIT
    
Function Init
           
var /GLOBAL REQUIREDSIZE
        
; === Destroy size lol ===

        
StrCpy $0 0
        
${If} ${SectionIsSelected} $0
                SectionGetSize 
$${Main} $1
                SectionGetSize 
$${arabic} $1
                SectionGetSize 
$${bulgarian} $1
                SectionGetSize 
$${tradChinese} $1
                SectionGetSize 
$${czech} $1
                SectionGetSize 
$${danish} $1
                SectionGetSize 
$${german} $1
                SectionGetSize 
$${greek} $1
                SectionGetSize 
$${English} $1
                SectionGetSize 
$${spanish} $1
                SectionGetSize 
$${finnish} $1
                SectionGetSize 
$${french} $1
                SectionGetSize 
$${hebrew} $1
                SectionGetSize 
$${hungarian} $1
                SectionGetSize 
$${italian} $1
                SectionGetSize 
$${japanese} $1
                SectionGetSize 
$${korean} $1
                SectionGetSize 
$${dutch} $1
                SectionGetSize 
$${polish} $1
                SectionGetSize 
$${portugueseBr} $1
                SectionGetSize 
$${romanian} $1
                SectionGetSize 
$${russian} $1
                SectionGetSize 
$${croatian} $1
                SectionGetSize 
$${albanian} $1
                SectionGetSize 
$${swedish} $1
                SectionGetSize 
$${thai} $1
                SectionGetSize 
$${turkish} $1
                SectionGetSize 
$${ukrainian} $1
                SectionGetSize 
$${belarusian} $1
                SectionGetSize 
$${slovenian} $1
                SectionGetSize 
$${Vietnamese} $1
                SectionGetSize 
$${mongolian} $1
                SectionGetSize 
$${nepali} $1
                SectionGetSize 
$${simpChinese} $1
                SectionGetSize 
$${portuguese} $1
                SectionGetSize 
$${serbianLatin} $1
                SectionGetSize 
$${serbian} $1

                SectionGetSize 
$${Free} $1
                SectionGetSize 
$${Professional} $1
            IntOp 
$$+ $1
        
${EndIf}    
        
InTop $$1024 KBytes -> Bytes
        IntOp 
$$1000000
        IntOp 
$$1000000
        StrCpy 
$$2 2 0
        IntOp 
$$1048576
        IntOp 
$$1048576
        StrCpy 
$$4 2 0
        SectionSetSize 
$${Main"0" ;use ($1,$2 MB) ;or ($3,$4 MB)
        
Strcpy $REQUIREDSIZE '$3,$4 MB'
        
SectionSetSize $${arabic0
        SectionSetSize 
$${bulgarian0
        SectionSetSize 
$${tradChinese0
        SectionSetSize 
$${czech0
        SectionSetSize 
$${danish0
        SectionSetSize 
$${german0
        SectionSetSize 
$${greek0
        SectionSetSize 
$${English0
        SectionSetSize 
$${spanish0
        SectionSetSize 
$${finnish0
        SectionSetSize 
$${french0
        SectionSetSize 
$${hebrew0
        SectionSetSize 
$${hungarian0
        SectionSetSize 
$${italian0
        SectionSetSize 
$${japanese0
        SectionSetSize 
$${korean0
        SectionSetSize 
$${dutch0
        SectionSetSize 
$${polish0
        SectionSetSize 
$${portugueseBr0
        SectionSetSize 
$${romanian0
        SectionSetSize 
$${russian0
        SectionSetSize 
$${croatian0
        SectionSetSize 
$${albanian0
        SectionSetSize 
$${swedish0
        SectionSetSize 
$${thai0
        SectionSetSize 
$${turkish0
        SectionSetSize 
$${ukrainian0
        SectionSetSize 
$${belarusian0
        SectionSetSize 
$${slovenian0
        SectionSetSize 
$${Vietnamese0
        SectionSetSize 
$${mongolian0
        SectionSetSize 
$${nepali0
        SectionSetSize 
$${simpChinese0
        SectionSetSize 
$${portuguese0
        SectionSetSize 
$${serbianLatin0
        SectionSetSize 
$${serbian0

        SectionSetSize 
$${Free"0"
        
SectionSetSize $${Professional"0"

        
; === Other actions ===
        
StrCpy $${Free}
    
FunctionEnd
!endif

# MOUSE

Function '.onMouseOverSection'
        
FindWindow $R0 "#32770" "" $HWNDPARENT
        GetDlgItem $R0 $R0 1043 
description item
        
${If} $== -1
              CreateFont 
$"Arial" 9 500 create the font for the default description

              SetCtlColors $R0 0x5f5f61 0xF0F0F0
              SendMessage $R0 
${WM_SETFONT} $1 0
              EnableWindow $R0 0
                  SendMessage $R0 
${WM_SETTEXT"STR:Position your mouse over a component to see its description."
        
${Else}
            
CreateFont $"Arial" 9 400 create the font for mouse over descriptions

        SetCtlColors $R0 0x5f5f61 0xF0F0F0
            SendMessage $R0 
${WM_SETFONT} $1 0
            EnableWindow $R0 1
        
${If} $== 0
              SendMessage $R0 
${WM_SETTEXT"STR:Select components for this program"

        
${ElseIf} $== 1

              SendMessage $R0 
${WM_SETTEXT"STR:Select components for this program"

        
${ElseIf} $== 2

              SendMessage $R0 
${WM_SETTEXT"STR:Install ${APP} Free Version"

        
${ElseIf} $== 3

              SendMessage $R0 
${WM_SETTEXT"STR:Install ${APP} Pro Version"

        
${ElseIf} $== 4

              SendMessage $R0 
${WM_SETTEXT"STR:Install aditional language for ${APP}"

        
${ElseIf} $== 5

              SendMessage $R0 
${WM_SETTEXT"STR:Install aditional language for ${APP}"

        
${ElseIf} $== 6

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Albanian"'

        
${ElseIf} $== 7

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Arabic"'

        
${ElseIf} $== 8

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Belarusian"'

        
${ElseIf} $== 9

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Bulgarian"'

        
${ElseIf} $== 10

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Chinese Simplified"'

        
${ElseIf} $== 11

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Chinese Traditional"'

        
${ElseIf} $== 12

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Croatian"'

        
${ElseIf} $== 13

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Czech"'

        
${ElseIf} $== 14

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Danish"'

        
${ElseIf} $== 15

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Dutch"'

        
${ElseIf} $== 16

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "English"'

        
${ElseIf} $== 17

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Finnish"'

        
${ElseIf} $== 18

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "French"'

        
${ElseIf} $== 19

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "German"'

        
${ElseIf} $== 20

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Greek"'

        
${ElseIf} $== 21

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Hebrew"'

        
${ElseIf} $== 22

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Italian"'

        
${ElseIf} $== 23

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Japanese"'

        
${ElseIf} $== 24

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Korean"'

        
${ElseIf} $== 25

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Mongolian"'

        
${ElseIf} $== 26

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Nepali"'

        
${ElseIf} $== 27

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Polish"'

        
${ElseIf} $== 28

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Portuguese"'

        
${ElseIf} $== 29

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Portuguese Brasilian"'

        
${ElseIf} $== 30

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Romanian"'

        
${ElseIf} $== 31

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Russian"'

        
${ElseIf} $== 32

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Serbian"'

        
${ElseIf} $== 33

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Serbian Latin"'

        
${ElseIf} $== 34

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Slovenian"'

        
${ElseIf} $== 35

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Spanish"'

        
${ElseIf} $== 36

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Swedish"'

        
${ElseIf} $== 37

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Thai"'

        
${ElseIf} $== 38

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Turkish"'

        
${ElseIf} $== 39

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Ukrainian"'

        
${ElseIf} $== 40

              SendMessage $R0 
${WM_SETTEXT'STR:Install Language: "Vietnamese"'

        
${EndIf}

        ${EndIf}
FunctionEnd 
Attached Files
File Type: nsi Installer.nsi (17.0 KB, 46 views)
Coby is offline   Reply With Quote