Archive: Check boxes not working


Check boxes not working
Hi,

I have tried several scripts with checkboxes including the one below. For some reason when the checkbox is checked, the functions associated with the checkbox are not running.
Any Ideas??


;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; Finish page
CheckBitmap "${NSISDIR}\Contrib\Graphics\Checks\aquachecks.bmp"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Edit Agent.ini Configuration File"
!define MUI_FINISHPAGE_RUN_FUNCTION "runfile"
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Edit Default.txt Configuraton File"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "runfile2"

Function "runfile"
ExecWait "$INSTDIR\${PROJ_NAME}Agent.ini"
FunctionEnd

Function "runfile2"
ExecWait "$INSTDIR\${PROJ_NAME}default.txt"
FunctionEnd

!define MUI_PAGE_CUSTOMFUNCTION_PRE PreFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveFinishPage

Function PreFinishPage
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "NumFields" "6"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Type" "CheckBox"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Text" "Start ${PROJ_NAME} Service"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Left" "120"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Right" "315"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Top" "130"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Bottom" "140"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "State" "0"
;line above: Initial state of the control: 0=Unchecked, 1=Checked
FunctionEnd

Function ShowFinishPage
GetDlgItem $MUI_TEMP1 $MUI_HWND 1205 ;ID for the 6th InstallOptions control
SetCtlColors $MUI_TEMP1 "" "${MUI_BGCOLOR}"
FunctionEnd

Function LeaveFinishPage
!insertmacro MUI_INSTALLOPTIONS_READ $MUI_TEMP1 "ioSpecial.ini" "Field 6" "State"
StrCmp $MUI_TEMP1 1 Checked Unchecked
Checked: nsSCM::start /NOUNLOAD "${PROJ_NAME}"
Goto end
Unchecked:
end:
FunctionEnd

!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES


Have you tried adding another command to your "Checked" label? There's only one command there, so do you know for sure that there's not a problem with that plugin?

Suggestion:
...
Checked:
MessageBox MB_OK "checkbox state is ${MUI_TEMP1}"
nsSCM::start /NOUNLOAD "${PROJ_NAME}"
Goto end
...

If the debug message box displays, then the problem is probably with the plugin call. If not, then the state of the checkbox must not be getting read correctly.


I have it working now. I forgot the back slash before the files:

Function "runfile"
ExecWait "$INSTDIR\${PROJ_NAME}\Agent.ini"
FunctionEnd

Function "runfile2"
ExecWait "$INSTDIR\${PROJ_NAME}\default.txt"
FunctionEnd


Ahhh the simple things!

A problem I am still having is the 3rd checkbox is to start a service if checked. I have confirmed the check box works properly, but the nsSCM::start /NOUNLOAD "${FILE_NAME}" does not start the service.

I install the service else where in the install as below and it works properly. Why won't the service start? I can also start it manually within the SCM with no problems.

nsSCM::Install /NOUNLOAD "${FILE_NAME}" "${FILE_NAME} service" 16 3 \
"$INSTDIR\${FILE_NAME}\${FILE_EXEC} /service" "" "" "" ""