Disable controls on custom page when checkbox checked
I have created a custom page and as part of this page I want 2 textboxes to disable if a checkbox is checked and then enable if the checkbox is unchecked.
I have tried techniques described the user manual but have had no joy.
I want to do this in the nsDialogsPageCheckChange function.
Here is my installer script:
# This is a test of the MSSQL OLEDB plugin that can be used to connect to a SQL Server instance
# and execute commands and scripts
# The installer includes a custom page which allows you to enter the network name of the sql server,
# whether windows authentication is used or not and a username and password if required
# This custom page also includes a Skip button if the user does not know this details
Name "MSSQL:OLEDB Plugin Test"
outfile 'customtest.exe'
!include 'MUI.nsh'
!include 'nsDialogs.nsh'
Var Dialog
Var Label
Var Text
Var Check
!insertmacro MUI_LANGUAGE "English"
page custom CustomPage nsDialogsPageLeave
Function customPage
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
; put controls onto the custom page
; parameters - x, y, width, height and text
${NSD_CreateLabel} 0 0 100% 20u "Enter the details for your SQL Server login below and then click Next to create an EmployerSafe database on the specified SQL Server."
Pop $Label
${NSD_CreateLabel} 0 20u 100% 20u "If you do not know these details, click on Skip and request that an IT administrator creates the Employersafe database using the supplied database creation script."
Pop $Label
${NSD_CreateLabel} 0 60u 30% 10u "SQL Server machine name:"
Pop $Label
${NSD_CreateText} 90u 60u 50% 13u ""
Pop $Text
${NSD_CreateLabel} 0 80u 30% 10u "Authentication details:"
Pop $Label
${NSD_CreateCheckBox} 90u 80u 70% 10u "Use Windows Authentication"
Pop $Check
${NSD_OnChange} $Check nsDialogsPageCheckChange
${NSD_CreateLabel} 0 95u 30% 10u "Username:"
Pop $Label
${NSD_CreateText} 90u 95u 50% 13u ""
Pop $Text
${NSD_CreateLabel} 0 110u 30% 10u "Password:"
Pop $Label
${NSD_CreateText} 90u 110u 50% 13u ""
Pop $Text
nsDialogs::Show
FunctionEnd
Function nsDialogsPageCheckChange
; Unchecked = 0, Checked = 1
${NSD_GetState} $Check $1
${If} $Check == 0
; enable username and password textboxes
${Else}
; disable username and password textboxes
${EndIf}
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $Text $0
MessageBox MB_OK "You typed:$\n$\n$0"
; Unchecked = 0, Checked = 1
${NSD_GetState} $Check $1
MessageBox MB_OK "$1"
FunctionEnd
Section ""
SectionEnd