Archive: Why the custom page did not show what's in the ini file?


Why the custom page did not show what's in the ini file?
I have a custom page which to show a box for user input. However the custom page is blank, did not show what's specified in my ini file. Can anyone help please?

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "server.ini" "SERVERIP"
FunctionEnd

Function SetCustom
Push $0
InstallOptions::initDialog /NOUNLOAD SERVERIP
Pop $0
InstallOptions::show
Pop $0
FunctionEnd

Function LeaveCustom
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "SERVERIP" "Field 5" "State"
StrCmp $R1 0 +2
...
FunctionEnd

server.ini:
[Settings]
NumFields=5

[Field 1]
Type=Label
Text=server
Left=0
Right=100
Top=1
Bottom=13

[Field 2]
Type=Text
State=test-server
Left=104
Right=204
Top=1
Bottom=13
Flags=

[Field 3]
Type=Label
Text=Port:
Left=208
Right=228
Top=1
Bottom=13

[Field 4]
Type=Text
State=8080
Left=232
Right=260
Top=1
Bottom=13
Flags=ONLY_NUMBERS

[Field 5]
Type=CheckBox
Text=Use this address for all service
State=0
Left=8
Right=-1
Top=17
Bottom=29
Flags=NOTIFY


Okay, I had a work around. In my .onInit function, I use

InitPluginsDir
File /oname=$PLUGINSDIR\SERVERIP "server.ini"

instead of
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "server.ini" "SERVERIP"

Now, I can see content I specified in my ini file.

The question is, what's the difference between InitPluginDir and MUI_INSTALLOPTIONS_EXTRACT_AS?


One more thing is, I clicked on the Checkbox, I did not see it's calling LeaveCustom function, why?


Use InstallOptions with MUI macros as shown below:

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioFile.ini"
FunctionEnd

immediately show dialog:
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioFile.ini"

init dialog:
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioFile.ini"

show it afterwards:
!insertmacro MUI_INSTALLOPTIONS_SHOW

HELP references:

for using InstallOptions with MUI:
see inbuilt NSIS MUI help - chapter 2.5 -> click Modern UI Readme ->expand all -> almost at the end "Using InstallOptions for custom pages"

examples:
see C:\Programme\NSIS\Examples\Modern UI\InstallOptions.nsi

---

For capturing Button klicks:

background info:
file:///C:/Programme/NSIS/Docs/InstallOptions/Readme.html

for examples with MUI macros:
see C:\Programme\NSIS\Examples\InstallOptions\testnotify.nsi

You have to decide, whether you use the MUI macros or you use the Installoptions functions. Its a matter of taste.