Archive: Install Options: Save Question


Install Options: Save Question
Hi,

i am searching for the easiest way to save the data in the Labels and restore them while switching between the boxes.
My Custom Page:

http://img347.imageshack.us/img347/3...ot00243uj2.jpg

Every Checkbox on the left side have their own labels.
I hope I have expressed myself clearly enough and you understand what I mean.

Thanks in advance


I'm not really sure if I got your point.
Compile and examine the code below to see if it could help you do what you're looking for.

outfile 'CheckboxNotify.exe'
showinstdetails show
licenseData '${NSISDIR}\License.txt'

!define NOCHECKED_TEXT 'Please select a checkbox'

!include WinMessages.nsh
!include LogicLib.nsh

page license
page custom CustomCreate CustomLeave
page instfiles

section -

sectionend

function .onInit
initpluginsdir
gettempfilename $0
rename $0 '$PLUGINSDIR\custom.ini'
call WriteIni
functionend

function CustomCreate
push $R1
InstallOptions::InitDialog /NOUNLOAD '$PLUGINSDIR\custom.ini'
pop $R1
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
InstallOptions::Show '$PLUGINSDIR\custom.ini'
pop $R1
functionend

function CustomLeave
readinistr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
${if} $0 == 1
readinistr $1 '$PLUGINSDIR\custom.ini' 'Field 1' 'Text'
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 5' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:$1'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:${NOCHECKED_TEXT}'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
${endif}
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 2' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
abort
${elseif} $0 == 2
readinistr $1 '$PLUGINSDIR\custom.ini' 'Field 2' 'Text'
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 5' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 2' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:$1'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:${NOCHECKED_TEXT}'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
${endif}
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 1' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 3' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
abort
${elseif} $0 == 3
readinistr $1 '$PLUGINSDIR\custom.ini' 'Field 3' 'Text'
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 5' 'HWND'
readinistr $3 '$PLUGINSDIR\custom.ini' 'Field 3' 'State'
${if} $3 == 1
SendMessage $2 ${WM_SETTEXT} 1 'STR:$1'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
${else}
SendMessage $2 ${WM_SETTEXT} 1 'STR:${NOCHECKED_TEXT}'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
${endif}
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 1' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
readinistr $2 '$PLUGINSDIR\custom.ini' 'Field 2' 'HWND'
SendMessage $2 ${BM_SETCHECK} 0 0
abort
${endif}
functionend

function WriteIni
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '5'

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' 'Checkbox one'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '0'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'NOTIFY'

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '18'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '32'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'Checkbox two'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'State' '0'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Flags' 'NOTIFY'

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Type' 'Checkbox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Left' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Top' '36'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Right' '100'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Bottom' '50'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Text' 'Checkbox three'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'State' '0'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 3' 'Flags' 'NOTIFY'

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Type' 'GroupBox'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Left' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Top' '70'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Right' '-31'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Bottom' '120'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 4' 'Text' 'Select Checkbox'

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Left' '40'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Top' '90'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Right' '-41'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'Bottom' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 5' 'State' '${NOCHECKED_TEXT}'
Functionend

First I want to thank you for writing the code for me.
But unfortunately this isn't what I want to do. But I think I didn't express myself good enough.
You're reading the text of the checkbox and send it to the label using SendMessage.
I want to save the text in the labels separate for every checkboxes. I will try to make an example:
If I type "This is a test 1" into CB_1_1 and "This is a test 2" into CB_1_2 and I select another CheckBox the labels should disappear empty. Now you type some other text into the labels. If I select CB_1 again the text I type in before ("This is a test 1" & "This is a test 2") should be restored.

I hope you understand me now.


I understand you :-)
I believe the provided above code example would help you understand the NOTIFY flag and therefore manage those things that you're looking for. It's just a few steps forward.