Archive: Clearing fields


Clearing fields
Just spent the last week writing an installer with bells and whistles, and hit a problem. Scenario: I have several custom pages which I use to collect info. Some of the info is repeated and so the custom pages have to be repeated with cleared fields. There are various fields which are dynamically greyed out depending on what on the page is selected.

I did start of with a "Page custom startFn leaveFn" which handles the NOTIFY to grey out the buttons. But found that there was no way to clear a text field. I did use MUI_INSTALLOPTIONS_WRITE but found that you really need to call MUI_INSTALLOPTIONS_DISPLAY to redraw the screen with the new changes.

Then I looked at the mathtest.nsi to figure out how to repeatedly show the same screen, and found that it uses MUI_INSTALLOPTIONS_DISPLAY_RETURN to stay in the startFn and loop until it's ok. MUI_INSTALLOPTIONS_DISPLAY_RETURN only returns Success or Failed, so there is no way to tell if one of my custom buttons is being called.

I'm a bit confused about how I can submit a page (maybe from a custom button), have it do something and then clear all the fields.

Any help would be appreciated.


The INI file is not reloaded when after the leave function returns. It's only rewritten before the leave function is called.

To change fields, you should use the same method you've used to disable them. Only instead of using EnableWindow, you use SendMessage ${WM_SETTEXT}.

Take a look at the custom page leave function in Examples\InstallOptions\testnotify.nsi. It shows you how to do it.


Thanks for the fast response.

'wparam' seems to be what you want to set it to, but what is 'lparam' for?

Is there some documentation for SendMessage which describes which types of dialog box, need what message in order to do what action/job?
There seems to be a lot of "SendMessage $0 $1 0x0123 0" (or whatever) entries which don't describe where 0x0123 came from.


lParam is not used in the case of WM_SETTEXT and should be set to zero. WM_SETTEXT is a standard window message and is best described in MSDN. MSDN contains reference to all available messages.


Ok, one final thing on the same lines. The box I am trying to fill in is a multi-line readonly text box. I read a file which contains:

1|1|1
2|2|2

into $0 and give it to MUI_INSTALLOPTIONS_WRITE but it only displays the 1st line. So I have to read the file in and replace the \r\n with actual "\r\n". Presumerably because there is an INI file behind and it only accepts single line entries.

However when I call SendMessage and give it the converted read-from-file string containing actual "\r\n" it prints these in the boxes.

Are there any built in functions that can help here, or do I have to handle each case with my own functions.


The InstallOptions readme contains Io2Nsis and Nsis2Io which do exactly that. WordReplace can also help here.


Excellent thanks for you help. Things are progressing nicely. Why aren't Io2Nsis and Nsis2Io included in the standard distribution?


They are. That readme is located in the Docs folder in your installation.


I mean in a nsh file. With all the other useful functions.


Because that change could be easily implemented using WordReplace in WordFunc.nsh.


Ok. Thanks for you help on this one. Shalom!