I was trying to include a check box in my uninstaller. I was able to put the check box in place. But when I try to get the state of check box it always returns 0 even though check box is checked. Here is the code I am using
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_FINISH
Function un.ModifyUnWelcome
${NSD_CreateCheckbox} 120u -18u 50% 25u "Do something special"
Pop $mycheckbox
SetCtlColors $mycheckbox "" ${MUI_BGCOLOR}
${NSD_Check} $mycheckbox ; Check it by default
FunctionEnd
Function un.LeaveUnWelcome
${NSD_GetState} $mycheckbox $0
MessageBox MB_OK "On Leave mycheckbox = $mycheckbox $\n $$0 = $0"
${If} $0 <> 0
MessageBox mb_ok "I'm special"
${EndIf}
FunctionEnd
As a result I could not verify if the check box is checked or not. what is wrong with my code and how can I fix it?
I even tried something like below
${NSD_Check} $mycheckbox ; Check it by default
${NSD_SetState} $mycheckbox ${BST_CHECKED}
I got the above code from Adding a checkbox to the NSIS Uninstaller Welcome Page
Your custom functions referred to two different pages. ModifyUnWelcome is calling when creates MUI_UNPAGE_WELCOME page, LeaveUnWelcome - when user leaves last MUI_UNPAGE_FINISH page. Control, owned by handle at ModifyUnWelcome will be destroyed at the moment when you are calling ${NSD_GetState}. You should to place custom functions definitions near each other and before referred page declaration.
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!insertmacro MUI_UNPAGE_FINISH