Old 30th January 2007, 17:31   #1
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
enable/disable "Next" button with checkbox

Hello,

I've written some code to disable and enable the "Next" Button on a custom page:
PHP Code:
Welcome page
!insertmacro MUI_PAGE_WELCOME
;Custum Function
Page custom showCheckSummary leaveCheckSummary
License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "Prototype.txt"
Directory page
!insertmacro MUI_PAGE_DIRECTORY
Instfiles page
!insertmacro MUI_PAGE_INSTFILES
Finish page
!insertmacro MUI_PAGE_FINISH

Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"

MUI end ------

Name "${PRODUCT_NAME}"
OutFile "Setup_ADEPAut.exe"

VAR INI_VALUE
VAR ERROR_MESSAGE
VAR hwnd

Function showCheckSummary
 
!insertmacro MUI_INSTALLOPTIONS_WRITE "checkSummary.ini" "FIELD 3" "State" "0"
  
GetDlgItem $hwnd $HWNDPARENT 1 ;AUSKOMMENTIEREN WENN FUNCTION MIT MSGBOX
  EnableWindow $hwnd 0           
;AUSKOMMENTIEREN WENN FUNCTION MIT MSGBOX
  
;Write values into Textfield
 
!insertmacro MUI_INSTALLOPTIONS_WRITE "checkSummary.ini" "FIELD 2" "State" "$ERROR_MESSAGE"
 
!insertmacro MUI_HEADER_TEXT "Summary" ""
 
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "checkSummary.ini"
 
 
;!insertmacro MUI_INSTALLOPTIONS_READ $INI_VALUE "checkSummary.ini" "FIELD 3" "STATE"
 
;strcmp $INI_VALUE 1
 
FunctionEnd


Function leaveCheckSummary
 
!insertmacro MUI_INSTALLOPTIONS_READ $INI_VALUE "checkSummary.ini" "FIELD 3" "STATE"
  
StrCmp $INI_VALUE 3 clicked notClicked
  notClicked
:
   
GetDlgItem $hwnd $HWNDPARENT 1 
   EnableWindow $hwnd 0
   Abort 
; Return to the page
  clicked
:
   
GetDlgItem $hwnd $HWNDPARENT 1
   EnableWindow $hwnd 1
FunctionEnd
    


Function .onInit

  
Extract InstallOptions files
  
$PLUGINSDIR will automatically be removed when the installer closes
  InitPluginsDir
  File 
/oname=$PLUGINSDIR\test.ini "checkSummary.ini"

 
strcpy $"false"

 
!insertmacro MUI_LANGDLL_DISPLAY

 
;Check Version-Number
 call CheckADVersion
 
 
;Read InstallDir
 call GetInstallDir
 StrCpy $INSTDIR 
"$R0"
 
StrCpy $INSTDIR "$INSTDIR..."
 
 
;Check Version-Number
 call CheckVersion

 
;CheckWindow
 strcmp 
$"true" equal notEqual
 equal
:
  !
insertmacro MUI_INSTALLOPTIONS_EXTRACT "checkSummary.ini"
 
notEqual:
FunctionEnd 
and here is my checkSummary.ini-File:

PHP Code:
[Settings]
NumFields=3
State
=0

[Field 1]
Type=label
Text
=Following Errors were found
Left=0
Right
=-1
Top
=0
Bottom
=10

[Field 2]
Type=text
Left
=0
Right
=-1
Top
=20
Bottom
=100
flags
=MULTILINE|VSCROLL|READONLY
State
="TEST"

[FIELD 3]
Type=CheckBox
NOtify
=
TEXTIgnore
FLAGS
=NOtify
State
=0
Left
=0
Right
=-
Top
=110 
Bottom
=120 
The Next-Button is correctly disabled. But when I do a click in the checkbox, the button is not enabled.

Where is the errror?

Any ideas?

Thank you very much...
Marcus1807 is offline   Reply With Quote
Old 30th January 2007, 17:42   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
You need to capture the checkbox with notify flag and re-enable the button when checkbox is checked.

See following example for details,

http://nsis.sourceforge.net/InstallO...of_NOTIFY_Flag

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump