I'm working on an NSIS installer. One of the requirements is to allow the user to input some information multiple times for multiple different entries (essentially, it allows them to enter server information for as many servers as they'd like). I'm currently recycling the pages by going to this page after my advanced options page:
Function RedirectPage
${If} $addtCheck <> 0 ; Was the checkbox checked?
StrCpy $startedXml 1 ; make this "true"
SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${Else}
Abort
${EndIf}
FunctionEnd
addtCheck
checks to see if the checkbox is ticked that recycles the page. If so this function causes the previous page to be displayed again. The problem is that the fields contain the information that the user just entered. Now, what I want to do is to clear the State of all of the fields of the previous page before they go back to it. I have tried doing something like this,
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioAdv.ini" "Field 2" "State" ""
but it doesn't seem to allow me to clear the state. I know of the SendMessage
and GetDlgItem
commands, but am unaware of any methods that allow me to use them to clear the text boxes, check boxes, and list boxes of contained in the InstallOptions INI file.
Anyone who can point me in the right direction, thanks. If you want to see any more of the script, let me know.
So you should have the controls in the ini like this:
[Field 1]
Type=Label
Left=15
Top=7
Right=112
Bottom=16
Text=Text 1
then you can get a handle on the field like this:
ReadIniStr $0 $PLUGINSDIR\page_ini.ini "Field 1" "HWND"
So then you can use the SendMessage
command with $0
like this:
SendMessage $0 ${WM_SETTEXT} 0 "STR:$InitialString"
This example should work on Text Boxes, for the other controls see the following:
In the NSIS Installation Path under "Include" there is the File Winmessages.nsh
with the Message Keys to use.
In my tests i found the key for setting checkboxes:
SendMessage $0 ${BM_SETCHECK} 0 "0"
For ListBoxes i found: (untested)
LB_RESETCONTENT
LB_SELECTSTRING
Hope that helps. PS: If you have any questions or critisism, please let me know.
PPS:
Alternatively, you could use the nsDialogs Macros with the HWND handle, i.e. for the Checkbox:
${NSD_Uncheck} $0
More Information to this Macros are here: nsDialogs Readme - Macros