- NSIS Discussion
- onselchange, onindexchange
Archive: onselchange, onindexchange
andreinho
6th March 2007 10:07 UTC
onselchange, onindexchange
hi at all,
i would like to know if someone have idea to how can activate or deactivate (set or reset readonly property) some text field in consequence of select or deselect a checkbox item. thanks so much in advance. bye
Andre
Red Wine
6th March 2007 12:46 UTC
Provided that you know the basics about InstallOptions, here is an example,
outfile 'test.exe'
!include logiclib.nsh
!include winmessages.nsh
page custom CustomCreate CustomLeave
page instfiles
section -
sectionend
function CustomCreate
push $1
InstallOptions::Dialog '$PLUGINSDIR\custom.ini'
pop $1
pop $1
functionend
function CustomLeave
readinistr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
${if} $0 == 1
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
EnableWindow $2 0
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field'
EnableWindow $2 1
${endif}
abort
${endif}
functionend
function .onInit
initpluginsdir
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '3'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '14'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Text' 'Sample Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '0'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '70'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-31'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '120'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'Sample Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Top' '90'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Right' '-41'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Bottom' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'State' 'Sample Text field'
functionend
andreinho
6th March 2007 14:15 UTC
see below
thank you so much red wine, with your suggest now
my checkbox work properly, but now i make u another question..........u use a enablewindow event, and if u check the checkox, enable or disable the window.....now, if i have more than one indipendent checkbox in the same windows i've some problem, i would like to know if exist a way to enable or disable only some text fields for example and not all the window. thanks so much in advance
bye
Andrew
Red Wine
6th March 2007 17:59 UTC
EnableWindow in the above example, enables/disables the specific text field, does not affect any other control nor the entire window.
andreinho
7th March 2007 08:47 UTC
see above
ok Red Wine, i've seen than with enablewindow i can enable/diable the single text field, i've tried to put in the same window 2 checkbox, the first enable/disable 2 text field, the second another text field. For the first checkbox all ok, work properly, instead for the second there are problems, if i check or uncheck the control, the installation program finish. Have u any idea? post the code, thanks so much. Andre
outfile 'test.exe'
!include logiclib.nsh
!include winmessages.nsh
page custom CustomCreate CustomLeave
page instfiles
section -
sectionend
function CustomCreate
push $1
InstallOptions::Dialog '$PLUGINSDIR\custom.ini'
pop $1
pop $1
functionend
function CustomLeave
readinistr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
${if} $0 == 1
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
readinistr $4 '$PLUGINSDIR\custom.ini' 'Field 4' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field'
SendMessage $4 ${WM_SETTEXT} 1 'STR:Sample Text field'
enablewindow $2 1
enablewindow $4 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
SendMessage $4 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
enablewindow $2 0
enablewindow $4 0
${endif}
readinistr $5 '$PLUGINSDIR\custom.ini' 'Field 7' 'HWND'
readinistr $6 '$PLUGINSDIR\custom.ini' 'Field 5' 'State'
${if} $6 == 1
SendMessage $5 ${WM_SETTEXT} 1 'STR:Sample Text field'
enablewindow $5 1
${else}
SendMessage $5 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
enablewindow $5 0
${endif}
abort
${endif}
functionend
function .onInit
initpluginsdir
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '7'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '14'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Text' '1 Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '1'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-11'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '80'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'a Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Left' '60'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Top' '55'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Right' '-21'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Bottom' '75'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'State' 'a Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Top' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Right' '-41'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Bottom' '50'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'State' 'b Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Top' '80'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Bottom' '92'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Text' '2 Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'State' '1'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Left' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Top' '95'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Right' '-11'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Bottom' '130'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Text' 'b Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Top' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Right' '-21'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Bottom' '125'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'State' 'c text'
functionend
Red Wine
7th March 2007 09:08 UTC
outfile 'test.exe'
!include logiclib.nsh
!include winmessages.nsh
page custom CustomCreate CustomLeave
page instfiles
section -
sectionend
function CustomCreate
push $1
InstallOptions::dialog '$PLUGINSDIR\custom.ini'
pop $1
pop $1
functionend
function CustomLeave
readinistr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
${if} $0 == 1
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
readinistr $4 '$PLUGINSDIR\custom.ini' 'Field 4' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field'
SendMessage $4 ${WM_SETTEXT} 1 'STR:Sample Text field'
enablewindow $2 1
enablewindow $4 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
SendMessage $4 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
enablewindow $2 0
enablewindow $4 0
${endif}
abort
${elseif} $0 == 5
readinistr $5 '$PLUGINSDIR\custom.ini' 'Field 7' 'HWND'
readinistr $6 '$PLUGINSDIR\custom.ini' 'Field 5' 'State'
${if} $6 == 1
SendMessage $5 ${WM_SETTEXT} 1 'STR:Sample Text field'
enablewindow $5 1
${else}
SendMessage $5 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
enablewindow $5 0
${endif}
abort
${endif}
functionend
function .onInit
initpluginsdir
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '7'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '14'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Text' '1 Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '1'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-11'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '80'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'a Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Left' '60'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Top' '55'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Right' '-21'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Bottom' '75'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'State' 'a Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Top' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Right' '-41'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Bottom' '50'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'State' 'b Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Top' '80'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Bottom' '92'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Text' '2 Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'State' '1'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Left' '20'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Top' '95'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Right' '-11'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Bottom' '130'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 6' 'Text' 'b Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Top' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Right' '-21'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'Bottom' '125'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 7' 'State' 'c text'
functionend
andreinho
7th March 2007 09:20 UTC
see above
perfect, i've understood how work,thank u very much Red Wine
andreinho
13th March 2007 10:00 UTC
see above
i've always a problem with enablewindow event,now text field are on and if i deselect checkbox they become grey, i would like to know if is possible and how, can i set the enablewindow property of a text field to 0 at start of page,grey textfield without readonly property, and enable it with enablewindow property to 1 when i select the checkbox. thanks so much.bye
Andre
Red Wine
13th March 2007 10:13 UTC
outfile 'test.exe'
!include logiclib.nsh
!include winmessages.nsh
page custom CustomCreate CustomLeave
page instfiles
section -
sectionend
function CustomCreate
push $1
InstallOptions::InitDialog /NOUNLOAD '$PLUGINSDIR\custom.ini'
pop $1
readinistr $1 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${unless} $1 == 1
readinistr $1 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
EnableWindow $1 0
${endunless}
InstallOptions::Show '$PLUGINSDIR\custom.ini'
pop $1
pop $1
pop $1
functionend
function CustomLeave
readinistr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
${if} $0 == 1
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field'
EnableWindow $2 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:Sample Text field disabled'
EnableWindow $2 0
${endif}
abort
${endif}
functionend
function .onInit
initpluginsdir
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '3'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '14'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Text' 'Sample Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '0'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'NOTIFY'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '70'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-31'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '120'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'Sample Groupbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Top' '90'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Right' '-41'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Bottom' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'State' 'Sample Text field disabled'
functionend