Archive: Controlling Available Install Options


Controlling Available Install Options
(from Wiki: http://nsis.sourceforge.net/Controll...nstall_Options)

Hi,

can i expand these option to 17 (or more) elements??

Thanks for your help.


Oh sorry.. have found my mistake! :)


Can be closed!


No, it is not working! :(

I have edited the value "SECTION_ON" to "SECTION_OFF" at some points, but now i have more SectionGroups! :(

What can i do?!


Yes, you can extend the example to cope with more components. For example, to make it work with 5 optional components three changes are needed:

(1) change

Section "optional #4" sec4
SectionEnd
to
Section "optional #4" sec4
SectionEnd

Section "optional #5" sec5
SectionEnd


(2) change
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0
to
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0

SectionGetFlags ${sec5} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec5} $0


(3) change
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${sec4}
to
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${sec4}
SectionGetFlags ${sec5} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${sec5}

Thanks. Yes, that works in this Example, but not in my Script. Why?

Here is Screenshot:

I have deleted SectionGroup, but it is in Groups, you can see it in Screenshot.


Now i see that didnt works with "MUI"-Pages.. :(

Maybe i can use custom Pages for this. So, i can also show Pictures from this Logos?!

But how can i asign files to that selection in custom page?

I will post my script later, so you can see what i mean.


Maybe anyone can take a look in my script?! :) That would be nice, thanks for your help.

; Define your application name
!define APPNAME "Aqua Skin"
!define APPNAMEANDVERSION "Aqua Skin"

; Main Install settings
Name "${APPNAMEANDVERSION}"

; use this Path if following Registry Key is not found
; InstallDir "$PROGRAMFILES\Centrafuse\Centrafuse Auto"

; the following Registry key is the Centrafuse standard key for Install Location
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\{9CB875EB-FCAC-4C67-B4A9-593E1D4B3759}" "InstallLocation"

OutFile "D:\SICHERUNG\_Car-PC\_Skinning\_Skins\Aqua\CFAquaV3.1.0.4.exe"

; registry entry
; InstallDirRegKey HKLM "Software\${APPNAME}" ""

; use modern XP style
XPStyle on

; don't show installations details
ShowInstDetails hide

; Installation Icon for the Installer itself
!define MUI_ICON "CF3.ico"

!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_TITLE_3LINES

; "skinlogo.bmp" for SkinInstaller, "pluginlogo.bmp" for PluginInstaller
!define MUI_WELCOMEFINISHPAGE_BITMAP "skinlogo.bmp"
; Use a header bitmap to display
!define MUI_HEADERIMAGE
; Select which Bitmap (must be BMP)
!define MUI_HEADERIMAGE_BITMAP "header.bmp"
; use this, if Bitmap is not exactly 150x57 pixels.
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADER_TRANSPARENT_TEXT

; Request application privileges for Windows Vista
RequestExecutionLevel admin

; Use compression
SetCompress force
SetCompressor /SOLID lzma

!include "Sections.nsh"
!define SECTION_ON ${SF_SELECTED} # 0x1

; Modern interface settings
!include "MUI.nsh"








; needed for custom logo selection dialog
!include "MUI2.nsh"
!include "winMessages.nsh"
!include "nsDialogs.nsh"
!addincludedir "."
!addplugindir "."

Section
SectionEnd

Var dialog
Var hwnd
;Var null

Var hwnd_listbox
Var hwnd_bitmap
Var res_bmp

!macro RedrawControl control
Push $0
EnableWindow $0 0
StrCpy $0 ${control}
System::Call "user32::InvalidateRect(i,i,i)i (r0, 0, 1)"
EnableWindow $0 1
Pop $0
!macroend
!define RedrawControl `!insertmacro RedrawControl`


Function custompage.droplist.onchange
Pop $hwnd
SendMessage $hwnd ${LB_GETCURSEL} 0 0 $0
${If} $0 >= 0
System::Call user32::SendMessage(i$hwnd,i${LB_GETTEXT},i$0,t.r1)
${Select} $1
${Case} "Alfa Romeo Logo"
StrCpy $3 "1.bmp"
${Case} "BMW Logo"
StrCpy $3 "2.bmp"
${Case} "3"
StrCpy $3 "3.bmp"
${Case} "4"
StrCpy $3 "4.bmp"
${Case} "5"
StrCpy $3 "5.bmp"
${Case} "6"
StrCpy $3 "6.bmp"
${Case} "7"
StrCpy $3 "7.bmp"
${Case} "8"
StrCpy $3 "8.bmp"
${Case} "9"
StrCpy $3 "9.bmp"
${Case} "10"
StrCpy $3 "10.bmp"
${Case} "11"
StrCpy $3 "11.bmp"
${Case} "12"
StrCpy $3 "12.bmp"
${Case} "13"
StrCpy $3 "13.bmp"
${Case} "14"
StrCpy $3 "14.bmp"
${Case} "15"
StrCpy $3 "15.bmp"
${Case} "16"
StrCpy $3 "16.bmp"
${Case} "17"
StrCpy $3 "17.bmp"
${Case} "18"
StrCpy $3 "18.bmp"
${Case} "19"
StrCpy $3 "19.bmp"
${Case} "20"
StrCpy $3 "20.bmp"
${Default}
StrCpy $3 "1.bmp"
${EndSelect}
${NSD_FreeImage} $res_bmp
${NSD_SetImage} $hwnd_bitmap "$PluginsDir\$3" $res_bmp
${EndIf}
FunctionEnd















; xml file handling plugin
!include "nsisXML.nsh"

; Logic library plugin
!include "LogicLib.nsh"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
!define MUI_LANGDLL_ALLLANGUAGES

!include FontReg.nsh
!include FontName.nsh

!define MUI_ABORTWARNING
!define MUI_ABORTWARNING_CANCEL_DEFAULT

!insertmacro MUI_PAGE_WELCOME
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "D:\SICHERUNG\_Car-PC\_Skinning\_Skins\Aqua\licensev3.1.0.4.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
Page custom custompage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; for Uninstaller, but currently i use no Uninstaller
; !insertmacro MUI_UNPAGE_CONFIRM
; !insertmacro MUI_UNPAGE_INSTFILES

; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_RESERVEFILE_LANGDLL

VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${PRODUCT_FULL_NAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "developed by Trevor Wernisch, Marcel Schlösser-Patz"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "www.centrafuse-skins.de"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © 2010 Trevor Wernisch, Marcel Schlösser-Patz"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" ${PRODUCT_VERSION}
VIProductVersion ${PRODUCT_VERSION}




; Sections 1
Section "Skin Files" Section1
SectionIn RO

; Set Section properties
SetOverwrite on

; Set Section Files and Shortcuts

SectionEnd


Section "Fonts" Section2
SectionIn RO

; Set Section properties
SetOverwrite on

; Set Section Files and Shortcuts
StrCpy $FONT_DIR $FONTS
!insertmacro InstallTTFFont 'GOTHIC.ttf'
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000

SectionEnd


Section "Visualization" Section3

; Set Section properties
SetOverwrite on

; Set Section Files and Shortcuts

SectionEnd


Section "Logo" Section4

; Set Section properties
SetOverwrite on

; Set Section Files and Shortcuts

SectionEnd


; how can i call this custom page only if it is selected in above selection dialog? (Section: "Logo")
Function customPage
nsDialogs::Create 1018
Pop $dialog

MessageBox MB_OK|MB_ICONEXCLAMATION "Please select your custom logo for this Skin!"

InitPluginsDir
SetOutPath "$PluginsDir"
File "1.bmp"
File "2.bmp"
File "3.bmp"
File "4.bmp"
File "5.bmp"
File "6.bmp"
File "7.bmp"
File "8.bmp"
File "9.bmp"
File "10.bmp"
File "11.bmp"
File "12.bmp"
File "13.bmp"
File "14.bmp"
File "15.bmp"
File "16.bmp"
File "17.bmp"
File "18.bmp"
File "19.bmp"
File "20.bmp"

${NSD_CreateListBox} 0 0 30% 100% ""
pop $hwnd_listbox
${NSD_LB_AddString} $hwnd_listbox "Alfa Romeo Logo"
${NSD_LB_AddString} $hwnd_listbox "BMW Logo"
${NSD_LB_AddString} $hwnd_listbox "3"
${NSD_LB_AddString} $hwnd_listbox "4"
${NSD_LB_AddString} $hwnd_listbox "5"
${NSD_LB_AddString} $hwnd_listbox "6"
${NSD_LB_AddString} $hwnd_listbox "7"
${NSD_LB_AddString} $hwnd_listbox "8"
${NSD_LB_AddString} $hwnd_listbox "9"
${NSD_LB_AddString} $hwnd_listbox "10"
${NSD_LB_AddString} $hwnd_listbox "11"
${NSD_LB_AddString} $hwnd_listbox "12"
${NSD_LB_AddString} $hwnd_listbox "13"
${NSD_LB_AddString} $hwnd_listbox "14"
${NSD_LB_AddString} $hwnd_listbox "15"
${NSD_LB_AddString} $hwnd_listbox "16"
${NSD_LB_AddString} $hwnd_listbox "17"
${NSD_LB_AddString} $hwnd_listbox "18"
${NSD_LB_AddString} $hwnd_listbox "19"
${NSD_LB_AddString} $hwnd_listbox "20"
${NSD_OnChange} $hwnd_listbox custompage.droplist.onchange

${NSD_CreateBitmap} 35% 0 190 171 ""
Pop $hwnd_bitmap

nsDialogs::Show
${NSD_FreeImage} $res_bmp
FunctionEnd



; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "Aqua Skin Files"
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "Font Installation"
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} "New Visual (RabbitHole)"
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} "Custom Logo"
!insertmacro MUI_FUNCTION_DESCRIPTION_END


;Section -FinishSection

; WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
; WriteUninstaller "$INSTDIR\uninstall.exe"

;SectionEnd


;Uninstall section (currently not used)
;Section Uninstall

;Remove from registry...
;DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
;DeleteRegKey HKLM "SOFTWARE\${APPNAME}"

; Delete self
;Delete "$INSTDIR\Skins\Classic Silver\uninstall.exe"

; Delete Shortcuts

; Clean up Skin Files
;Delete "$INSTDIR\Plugins\Cam\Skins\Classic Obsidian\cam_down.png"
;Delete "$INSTDIR\Plugi........

; Clean up Fonts
;Delete "$INSTDIR\Handel_Gothic_BT.ttf"
;Delete "$INSTDIR\Han.........

; Clean up Visuals
;Delete "$INSTDIR\Visuals\RabbitHole.txt"
;Delete "$INSTDIR\Visuals\rabbi........

; Remove remaining directories
;RMDir "$INSTDIR\Visuals\"
;RMDir "$INSTDIR\Skins\Classic Silver\screens\"
;RMDir "$INSTDIR\Skins\Classic Silver\phoneicons\"
;RMDir "$INSTDIR\Skins\Classic Silver\listview\"
;RMDir "$INSTDIR\Skins\Classic Silver\icons\"
;RMDir "$INSTDIR\Skins\Classic Silver\effectprofiles\"
;RMDir "$INSTDIR\Skins\Classic Silver\dial.........

;SectionEnd


; On initialization
Function .onInit

; show a splash screen
;;;InitPluginsDir
;;;File /oname=$PLUGINSDIR\splash.bmp "splash.bmp"
;;;advsplash::show 2300 300 300 -1 $PLUGINSDIR\splash
;;;Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normally, and '-1' if some error occurred.
; but this result is currently not used

; Checking if installer is running in more instances
;;;System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tpms") i .r1 ?e'
;;;Pop $R0
;;;StrCmp $R0 0 +3 ; if $R0 = 0 then jump 3 lines further, else goto next line (MessageBox and then abort)
;;;MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running!"
;;;Abort

; see if Centrafuse is running
;;;FindProcDLL::FindProc "centrafuse.exe"
;;;StrCmp $R0 1 0 +3
;;;MessageBox MB_ICONINFORMATION|MB_OK "Centrafuse is running. Please close Centrafuse and then re-run this Installer."
;;;Abort

; Checking for a valid installation path
; StrCmp $INSTDIR "" 0 +3
; MessageBox MB_OK|MB_ICONEXCLAMATION "The Centrafuse Install path cannot be found. Installation aborted!"
; Abort

!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd

BrandingText "www.centrafuse-skins.de"

Next time, pleeeeeeease use pastebin for that stuff?


What is "pastebin"?

And why?

Can anyone help me with above script?


pastebin is an online service where users can paste large pieces of text and code for community review. there's several.. pastebin.ca and pastebin.com being the most typical ones.

I don't know if I would recommend using them here - as it makes the posts depend on an external solution. If it's a large script, zip it up and attach it, instead.

As for your script - no time to peek at it right now, maybe later


It works so far ok. but i think i need variables to set the right section to install.

Maybe other user can help me. I need the solution very soon..

Thanks @ll.