Archive: Custom Pages, Modern Interface, and User Input


Custom Pages, Modern Interface, and User Input
  I created an ini file holding 2 textbox fields for a custom page while I'm using the modern2.exe as the MUI interface. I can't seem to figure out how to get what information the user has entered into the installer. Basically, I'm having the user input their registration information for the program on the install page, and then writing the settings to the registry for later use. If anyone could shed some light on this I'd greatly appreciate it. I've looked everwhere and still haven't found any documentation on it. Also, if anyone knows anything about making one of these fields required to continue that would also be great.

Thanks :)


I can't seem to figure out how to get what information the user has entered into the installer
The Contrib\InstallOptions.nsi example quite clearly shows how to work out in your script what state the controls were in when the page was closed.

If I recall it correctly:
TextBox controls (along with some others), write their return value back into the .ini file. Then you have to use ReadINIStr to read the values from the .ini file.


Use the MUI_INSTALLOPTIONS_READ macro (have a look at the Modern UI\InstallOptions.nsi example).

!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP} "inifile.ini" "Field #" "Text"

I looked at the file already I think, I currently have this in the nsi file:

!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP1} "ioA.ini" "Field 2" "Text"
!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP2} "ioA.ini" "Field 4" "Text"

My problem is getting the user data into the registry. What would that be?

WriteRegStr HKLM "Software\My Software" "Name" ${TEMP1} ??

I'm not sure exactly what to do from this point. Thanks again for the help everyone.


Exactly. The value will get into ${TEMP1} and ${TEMP2}.


Make sure that you defined TEMP1 and TEMP2, for example:

!define TEMP1 $R0 ;Will be stored in variable $R0


Yup, I have it defined earlier in the script.

!define TEMP1 $R0
!define TEMP2 $R1

Section ""

!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP1} "ioA.ini" "Field 2" "Text"
!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP2} "ioA.ini" "Field 4" "Text"

WriteRegStr HKLM "Software\MyProgram" "Name" $R0
WriteRegStr HKLM "Software\MyProgram" "Company" $R1

SectionEnd

This is what I currently have in my script. By the way, I just stuck the sections in there so you would know that I do have them in a section. Is there something that I'm missing? It just doesn't seem to want to work at all. I've tried using .... "Name" ${R0}, "Name" "${R0}", "Name" $R0, "Name" "$R0" and nothing just seems to work. I know its something small, things like this always are.


!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP1} "ioA.ini" "Field 2" "Text"
!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP2} "ioA.ini" "Field 4" "Text"

The name "Text" should be "State" (Text is the text that are show to user in labels, check boxes, radio buttons..., State is the state of the control after the user left the page).


YAY!
  Thanks for all the help everyone. Deguix got the problem fixed for me. I knew it'd be something small hehe. I'm just used to using most ActiveX control textboxes that hold the data in the Text property. Never occurred it could be held somewhere else.

Thanks again!

Here's what the finished script looked like:


define TEMP1 $R0

>!define TEMP2 $R1

Section"Core Files" SecCore

!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP1} "ioA.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ ${TEMP2} "ioA.ini" "Field 4" "State"

WriteRegStr HKLM "Software\\MySoftware" "Name" $R0
WriteRegStr HKLM"Software\\MySoftware" "Company" $R1

SectionEnd
>