0

I have a some different license pages with check box on it. The Next button should be disabled if check box is unchecked. Is there an event that I can use if checkbox state changed? Here is my code of one of this

var Window
var labelDescription
var checkBoxIsUserAgree

Function CreateCustomLicense1
  nsDialogs::Create 1018
  Pop $Window

  GetDlgItem $0 $HWNDPARENT
  EnableWindow $0 0
  ${NSD_CreateLabel} 13u 22u 270u 96u "Description"
  Pop $labelDescription
  ${NSD_CreateCheckBox} 10u 110u 100u 15u "I Agree"
  $checkBoxIsUserAgree
FunctionEnd

Function ShowCustomLicence1
  Call CreateCustomLicense1
  nsDialogs::Show
Function

Function .oncheckBoxIsUserAgreeStateChanged ; what event I can use for track checkbox state changing
 EnableWindow $0 1
FunctionEnd
3
  • It helps if you post code that actually compiles! Reading the documentation first might be a good idea as well...
    – Anders
    Aug 17, 2017 at 11:33
  • @Anders I try to find answer in documentation, but I was looking something wrong. I thought that it should be something like .onSelectedChanged for global page. I couldn't imagine than I can use ${NSD_...} as a function. Thx! Aug 17, 2017 at 11:57
  • 1
    NSD_ are helper macros, some just call nsDialogs::xyz...
    – Anders
    Aug 17, 2017 at 12:22

1 Answer 1

2

The built-in NSIS license page supports a checkbox and can be used multiple times but if you insist on creating a custom page you just have to add a on* handler:

!include nsDialogs.nsh

Var checkBoxIsUserAgree

Function ShowCustomLicence1
  nsDialogs::Create 1018
  Pop $1

  GetDlgItem $0 $HWNDPARENT 1
  EnableWindow $0 0
  ${NSD_CreateLabel} 13u 22u 270u 90u "Description"
  Pop $1
  ${NSD_CreateCheckBox} 10u 110u 100u 15u "I Agree"
  Pop $checkBoxIsUserAgree
  ${NSD_OnClick} $checkBoxIsUserAgree oncheckBoxIsUserAgreeStateChanged1

  nsDialogs::Show
FunctionEnd


Function oncheckBoxIsUserAgreeStateChanged1
  Pop $1 ; Throw away parameter
  ${NSD_GetState} $checkBoxIsUserAgree $1
  EnableWindow $0 $1
FunctionEnd

Page Custom ShowCustomLicence1
Page InstFiles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.