My installer allows to install a couple of applications.
at FINISHPAGE i want a checkbox to start a specific application (!define MUI_FINISHPAGE_RUN), but hide the checkbox if the user has unchecked it on componentspage. how can i do this with mui2?
Start Application after Install
3 posts
!include MUI2.nsh
!include Logiclib.nsh
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE CompLeave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT " RunFunction"
!define MUI_FINISHPAGE_RUN_FUNCTION "RunFunction"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW CustomFinish
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
var Checkbox1
var Checkbox2
var Checkbox3
Section "1" 1
SectionEnd
Section "2" 2
SectionEnd
Section "3" 3
SectionEnd
Function CompLeave
${If} ${SectionIsSelected} ${1}
StrCpy $R1 1
${EndIf}
${If} ${SectionIsSelected} ${2}
StrCpy $R2 1
${EndIf}
${If} ${SectionIsSelected} ${3}
StrCpy $R3 1
${EndIf}
FunctionEnd
Function CustomFinish
${NSD_CreateCheckbox} 120u 110u 100% 10u " Checkbox 1"
Pop $Checkbox1
${If} $R1 == 1
${NSD_SetState} $Checkbox1 1
${EndIf}
SetCtlColors $Checkbox1 "" "ffffff"
${NSD_CreateCheckbox} 120u 130u 100% 10u " Checkbox 2"
Pop $Checkbox2
${If} $R2 == 1
${NSD_SetState} $Checkbox2 1
${EndIf}
SetCtlColors $Checkbox2 "" "ffffff"
${NSD_CreateCheckbox} 120u 150u 100% 10u " Checkbox 3"
Pop $Checkbox3
${If} $R3 == 1
${NSD_SetState} $Checkbox3 1
${EndIf}
SetCtlColors $Checkbox3 "" "ffffff"
FunctionEnd
Function FinishLeave
${NSD_GetState} $Checkbox1 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox1 - ON"
${EndIf}
${NSD_GetState} $Checkbox2 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox2 - ON"
${EndIf}
${NSD_GetState} $Checkbox3 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox3 - ON"
${EndIf}
FunctionEnd
Function RunFunction
MessageBox mb_ok "RunFunction"
FunctionEnd
!include Logiclib.nsh
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE CompLeave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT " RunFunction"
!define MUI_FINISHPAGE_RUN_FUNCTION "RunFunction"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW CustomFinish
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
var Checkbox1
var Checkbox2
var Checkbox3
Section "1" 1
SectionEnd
Section "2" 2
SectionEnd
Section "3" 3
SectionEnd
Function CompLeave
${If} ${SectionIsSelected} ${1}
StrCpy $R1 1
${EndIf}
${If} ${SectionIsSelected} ${2}
StrCpy $R2 1
${EndIf}
${If} ${SectionIsSelected} ${3}
StrCpy $R3 1
${EndIf}
FunctionEnd
Function CustomFinish
${NSD_CreateCheckbox} 120u 110u 100% 10u " Checkbox 1"
Pop $Checkbox1
${If} $R1 == 1
${NSD_SetState} $Checkbox1 1
${EndIf}
SetCtlColors $Checkbox1 "" "ffffff"
${NSD_CreateCheckbox} 120u 130u 100% 10u " Checkbox 2"
Pop $Checkbox2
${If} $R2 == 1
${NSD_SetState} $Checkbox2 1
${EndIf}
SetCtlColors $Checkbox2 "" "ffffff"
${NSD_CreateCheckbox} 120u 150u 100% 10u " Checkbox 3"
Pop $Checkbox3
${If} $R3 == 1
${NSD_SetState} $Checkbox3 1
${EndIf}
SetCtlColors $Checkbox3 "" "ffffff"
FunctionEnd
Function FinishLeave
${NSD_GetState} $Checkbox1 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox1 - ON"
${EndIf}
${NSD_GetState} $Checkbox2 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox2 - ON"
${EndIf}
${NSD_GetState} $Checkbox3 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox3 - ON"
${EndIf}
FunctionEnd
Function RunFunction
MessageBox mb_ok "RunFunction"
FunctionEnd
All you have to do is to detect if the section is unchecked and if it is you modify the finish page. IMHO it would be enough to just uncheck the checkbox but my example also hides it because that is what you requested:
!include MUI2.nsh
!include Logiclib.nsh
!include Sections.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$sysdir\calc.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyFinishPage
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Section "Create shortcuts" SID_LNK
; CreateShortcut ...
SectionEnd
Function ModifyFinishPage
${IfNot} ${SectionIsSelected} ${SID_LNK}
SendMessage $mui.FinishPage.Run ${BM_SETCHECK} ${BST_UNCHECKED} 0
ShowWindow $mui.FinishPage.Run 0
${EndIF}
FunctionEnd